SplitWhereView
public struct SplitWhereView { /* private fields */ }Lazy view over the segments of a string split at every code point matching a predicate. The matching characters are excluded from segments.
Examples
let view = "hello world".asSlice().split { (c) in c == Char(" ") };
view.first(); // Some("hello")
view.count; // 2Properties
public var count: Int64 { get }
public var count: Int64 { get }Number of segments. O(n) — iterates once to count.
public var first: StringSlice? { get }
public var first: StringSlice? { get }The first segment, or .None if empty.
public var isEmpty: Bool { get }
public var isEmpty: Bool { get }True when the source slice is empty.
public var last: StringSlice? { get }
public var last: StringSlice? { get }The last segment, or .None if empty.
Initializers
public init(slice: StringSlice, where: consuming (Char) -> Bool)
public init(slice: StringSlice, where: consuming (Char) -> Bool)Methods
public func collect() -> Array[StringSlice]
public func collect() -> Array[StringSlice]Collects all segments into an array.
ImplementsIterable
Associated Types
type Item = StringSlice
type Item = StringSlicetype TargetIterator = SplitWhereViewIterator
type TargetIterator = SplitWhereViewIteratorMethods
public func iter() -> SplitWhereViewIterator
public func iter() -> SplitWhereViewIteratorImplementsCloneable
Methods
public func clone() -> SplitWhereView
public func clone() -> SplitWhereViewDefined in lang/std/text/views.ks