SplitView

public struct SplitView { /* private fields */ }

Lazy view over the segments of a string split on a fixed separator.

Each segment is a zero-copy StringSlice into the original buffer. Use iter() for one-pass iteration, or first()/last()/collect() for targeted access.

Examples

let view = "a,b,c".asSlice().split(","); view.first(); // Some("a") view.count; // 3 view.collect(); // [StringSlice("a"), StringSlice("b"), StringSlice("c")]

Properties

public var count: Int64 { get }

Number of segments. O(n) — iterates once to count.

public var first: StringSlice? { get }

The first segment, or .None if empty.

public var isEmpty: Bool { get }

True when the source slice is empty.

public var last: StringSlice? { get }

The last segment, or .None if empty.

Initializers

public init(slice: StringSlice, separator: String)

Methods

public func collect() -> Array[StringSlice]

Collects all segments into an array.

ImplementsIterable

Associated Types

type Item = StringSlice
type TargetIterator = SplitViewIterator

Methods

public func iter() -> SplitViewIterator

ImplementsCloneable

Methods

public func clone() -> SplitView

Defined in lang/std/text/views.ks