Skip to content

Commit f4a81d1

Browse files
Azoynatecook1000
authored andcommitted
Remove a warning, some doc fixes (#16863)
usableFromInline -> inlinable More doc fixes Add some more inlines
1 parent d035caf commit f4a81d1

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

stdlib/public/core/Bool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public struct Bool {
9494
/// method to generate a random Boolean value when you are using a custom
9595
/// random number generator.
9696
///
97-
/// let flippedHeads = Boolean.random(using: &myGenerator)
97+
/// let flippedHeads = Bool.random(using: &myGenerator)
9898
/// if flippedHeads {
9999
/// print("Heads, you win!")
100100
/// } else {
@@ -116,7 +116,7 @@ public struct Bool {
116116
///
117117
/// This method returns `true` and `false` with equal probability.
118118
///
119-
/// let flippedHeads = Boolean.random()
119+
/// let flippedHeads = Bool.random()
120120
/// if flippedHeads {
121121
/// print("Heads, you win!")
122122
/// } else {

stdlib/public/core/Integers.swift.gyb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,11 @@ extension ${Range}
25772577
// Compute delta, the distance between the lower and upper bounds. This
25782578
// value may not representable by the type Bound if Bound is signed, but
25792579
// is always representable as Bound.Magnitude.
2580+
% if 'Closed' in Range:
25802581
var delta = Bound.Magnitude(truncatingIfNeeded: upperBound &- lowerBound)
2582+
% else:
2583+
let delta = Bound.Magnitude(truncatingIfNeeded: upperBound &- lowerBound)
2584+
% end
25812585
% if 'Closed' in Range:
25822586
// Subtle edge case: if the range is the whole set of representable values,
25832587
// then adding one to delta to account for a closed range will overflow.
@@ -4046,6 +4050,7 @@ public func _assumeNonNegative(_ x: ${Self}) -> ${Self} {
40464050
% end
40474051

40484052
extension ${Self} {
4053+
@inlinable
40494054
public static func _random<R: RandomNumberGenerator>(
40504055
using generator: inout R
40514056
) -> ${Self} {

stdlib/public/core/Random.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import SwiftShims
3232
/// }
3333
///
3434
/// static func random() -> Weekday {
35-
/// return Weekday.randomWeekday(using: &Random.default)
35+
/// return Weekday.random(using: &Random.default)
3636
/// }
3737
/// }
3838
///
@@ -60,6 +60,7 @@ public protocol RandomNumberGenerator {
6060
}
6161

6262
extension RandomNumberGenerator {
63+
@inlinable
6364
public mutating func _fill(bytes buffer: UnsafeMutableRawBufferPointer) {
6465
// FIXME: Optimize
6566
var chunk: UInt64 = 0
@@ -132,25 +133,29 @@ extension RandomNumberGenerator {
132133
/// - Apple platforms use `arc4random_buf(3)`.
133134
/// - Linux platforms use `getrandom(2)` when available; otherwise, they read
134135
/// from `/dev/urandom`.
136+
@_fixed_layout
135137
public struct Random : RandomNumberGenerator {
136138
/// The default instance of the `Random` random number generator.
139+
@inlinable
137140
public static var `default`: Random {
138141
get { return Random() }
139142
set { /* Discard */ }
140143
}
141144

142-
private init() {}
145+
@inlinable
146+
internal init() {}
143147

144148
/// Returns a value from a uniform, independent distribution of binary data.
145149
///
146150
/// - Returns: An unsigned 64-bit random value.
147-
@effects(releasenone)
151+
@inlinable
148152
public mutating func next() -> UInt64 {
149153
var random: UInt64 = 0
150154
_stdlib_random(&random, MemoryLayout<UInt64>.size)
151155
return random
152156
}
153157

158+
@inlinable
154159
public mutating func _fill(bytes buffer: UnsafeMutableRawBufferPointer) {
155160
if !buffer.isEmpty {
156161
_stdlib_random(buffer.baseAddress!, buffer.count)

0 commit comments

Comments
 (0)