Files
swift-mirror/test/Serialization/Inputs/ncgenerics.swift
Allan Shortlidge 9e5a9b963f AST: Remove NoncopyableGenerics feature suppression.
It is no longer necessary to produce `.swiftinterface` files the support older
compilers that lack support for the NoncopyableGenerics feature. Cleaning this
up makes the stdlib `.swiftinterface` far more readable.
2024-07-08 17:44:24 -07:00

35 lines
727 B
Swift

public protocol Generator<Value> {
associatedtype Value
mutating func next() -> Value?
}
public struct Counter: Generator {
var state: Int = 0
public mutating func next() -> Int? {
let value = state
state += 1
return value
}
}
public func advance<T: Generator>(by n: Int, _ t: inout T) {
for _ in 0..<n {
_ = t.next()
}
}
public enum Maybe<Wrapped: ~Copyable>: ~Copyable {
case just(Wrapped)
case none
}
extension Maybe: Copyable where Wrapped: Copyable {}
public func ncIdentity<T: ~Copyable>(_ t: consuming T) -> T { return t }
public protocol Either<Left, Right>: ~Copyable {
associatedtype Left: ~Copyable
associatedtype Right: ~Copyable
}