|
@@ -13,10 +13,10 @@
|
|
// - This notice may not be removed or altered from any source or binary distribution.
|
|
// - This notice may not be removed or altered from any source or binary distribution.
|
|
//
|
|
//
|
|
|
|
|
|
-#if os(Linux) || os(Android) || os(FreeBSD)
|
|
|
|
- import Glibc
|
|
|
|
-#else
|
|
|
|
|
|
+#if canImport(Darwin)
|
|
import Darwin
|
|
import Darwin
|
|
|
|
+#else
|
|
|
|
+ import Glibc
|
|
#endif
|
|
#endif
|
|
|
|
|
|
struct RandomBytesSequence: Sequence {
|
|
struct RandomBytesSequence: Sequence {
|
|
@@ -24,8 +24,8 @@ struct RandomBytesSequence: Sequence {
|
|
|
|
|
|
func makeIterator() -> AnyIterator<UInt8> {
|
|
func makeIterator() -> AnyIterator<UInt8> {
|
|
var count = 0
|
|
var count = 0
|
|
- return AnyIterator<UInt8>.init({ () -> UInt8? in
|
|
|
|
- if count >= self.size {
|
|
|
|
|
|
+ return AnyIterator<UInt8>.init { () -> UInt8? in
|
|
|
|
+ guard count < self.size else {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
count = count + 1
|
|
count = count + 1
|
|
@@ -45,6 +45,6 @@ struct RandomBytesSequence: Sequence {
|
|
#else
|
|
#else
|
|
return UInt8(arc4random_uniform(UInt32(UInt8.max) + 1))
|
|
return UInt8(arc4random_uniform(UInt32(UInt8.max) + 1))
|
|
#endif
|
|
#endif
|
|
- })
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|