- Removed
.start
and.end
, now allOffsetBound
s are built from.first
and.last
.- Simplifies usage and learnability.
.last + 1
representing the end is mostly only relevant to documentation. - Better delineates
OffsetBound
abstraction and terminology from indices.
- Simplifies usage and learnability.
- Added RangeReplaceableCollection convenience overloads, as well as subscript setters.
.insert(at:)
,.remove(at:)
, etc.,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: doc | |
public struct OffsetBound { | |
internal enum Kind { | |
case fromStart(Int) | |
case fromEnd(Int) | |
} | |
internal var kind: Kind | |
init(fromStart: Int) { | |
self.kind = .fromStart(fromStart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: doc | |
public struct OffsetBound<Bound> { | |
internal enum Kind { | |
case fromStart(Int) | |
case fromEnd(Int) | |
} | |
internal var kind: Kind | |
public init(fromStart: Int) { | |
self.kind = .fromStart(fromStart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: doc | |
public struct OffsetBound { | |
internal enum Kind { | |
case fromStart(Int) | |
case fromEnd(Int) | |
} | |
internal var kind: Kind | |
public init(fromStart: Int) { | |
self.kind = .fromStart(fromStart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: doc | |
public struct OffsetBound<Bound> { | |
internal enum Kind { | |
case fromStart(Int) | |
case fromEnd(Int) | |
} | |
internal var kind: Kind | |
public init(fromStart: Int) { | |
self.kind = .fromStart(fromStart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: doc | |
public struct OffsetBound { | |
internal enum Kind { | |
case fromStart(Int) | |
case fromEnd(Int) | |
} | |
internal var kind: Kind | |
internal init(fromStart: Int) { | |
self.kind = .fromStart(fromStart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: doc | |
public struct OffsetBound { | |
internal enum Kind { | |
case fromStart(Int) | |
case fromEnd(Int) | |
} | |
internal var kind: Kind | |
internal init(fromStart: Int) { | |
self.kind = .fromStart(fromStart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// Collection Consumers | |
/// | |
protocol CollectionConsumer { | |
associatedtype Element | |
func consumeFront<C: Collection>(_ c: C) -> C.Index? where C.Element == Element | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct StringFormatters { | |
var text = "Hello, World!" | |
} | |
/* | |
This is the master template for fprintf format string functionality. | |
For development purposes only | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Eat/seek/peek | |
extension Collection where SubSequence == Self, Element: Equatable { | |
mutating func eat() -> Element { | |
defer { self = self.dropFirst() } | |
return peek() | |
} | |
mutating func eat(_ n: Int) -> SubSequence { | |
let (pre, rest) = self.seek(n) | |
defer { self = rest } |