mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[noescape by default] Proliferate @escaping
Adds an explicit @escaping throughout the standard library, validation test suite, and tests. This will be necessary as soon as noescape is the default for closure parameters.
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
/// value returned by passing the previous element to `next`.
|
||||
///
|
||||
/// - SeeAlso: `sequence(state:next:)`
|
||||
public func sequence<T>(first: T, next: (T) -> T?) -> UnfoldFirstSequence<T> {
|
||||
public func sequence<T>(first: T, next: @escaping (T) -> T?) -> UnfoldFirstSequence<T> {
|
||||
// The trivial implementation where the state is the next value to return
|
||||
// has the downside of being unnecessarily eager (it evaluates `next` one
|
||||
// step in advance). We solve this by using a boolean value to disambiguate
|
||||
@@ -86,7 +86,7 @@ public func sequence<T>(first: T, next: (T) -> T?) -> UnfoldFirstSequence<T> {
|
||||
/// - Returns: A sequence that yields each successive value from `next`.
|
||||
///
|
||||
/// - SeeAlso: `sequence(first:next:)`
|
||||
public func sequence<T, State>(state: State, next: (inout State) -> T?)
|
||||
public func sequence<T, State>(state: State, next: @escaping (inout State) -> T?)
|
||||
-> UnfoldSequence<T, State> {
|
||||
return UnfoldSequence(_state: state, _next: next)
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public struct UnfoldSequence<Element, State> : Sequence, IteratorProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
internal init(_state: State, _next: (inout State) -> Element?) {
|
||||
internal init(_state: State, _next: @escaping (inout State) -> Element?) {
|
||||
self._state = _state
|
||||
self._next = _next
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user