Files
divkit/client/ios/Core/Base/UnsignedIntegerExtenstions.swift
T
babaevmm f250ad7b40 open rw locks pr
add rw locks usage
2022-09-26 16:41:40 +03:00

14 lines
465 B
Swift

// Copyright 2019 Yandex LLC. All rights reserved.
extension UnsignedInteger where Self: FixedWidthInteger {
/// Creates a new instance from the given integer, if it can be represented
/// exactly. Otherwise `InvalidArgumentError` will be thrown.
@inlinable
public init<T: BinaryInteger>(value: T) throws {
guard let converted = Self(exactly: value) else {
throw InvalidArgumentError(name: "value", value: value)
}
self = converted
}
}