mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
That is, if we need a type MyIndex<T> to be a valid ForwardIndex, we should be able to find it in the conformance for BidirectionalIndex, which inherits from ForwardIndex. <rdar://problem/15484898> Swift SVN r11270
20 lines
389 B
Swift
20 lines
389 B
Swift
import Base
|
|
|
|
// Instantiate Counter<Int>, relying on Counter's adoption of ForwardIndex.
|
|
struct OneToAThousand : Indexable {
|
|
typealias Element = Int
|
|
typealias IndexType = Counter<Int>
|
|
|
|
func startIndex() -> IndexType {
|
|
return IndexType(1)
|
|
}
|
|
|
|
func endIndex() -> IndexType {
|
|
return IndexType(1001)
|
|
}
|
|
|
|
func __getitem__(i: IndexType) -> Element {
|
|
return i.value
|
|
}
|
|
}
|