Struct source_span::Layout[][src]

pub struct Layout<M: Metrics> { /* fields omitted */ }
Expand description

Text layout.

Keep track of the byte index of each line in a UTF8-encoded so it can be indexed by cursor position.

Implementations

Create a new empty layout from a given metrics.

Get the layout’s span.

Create a new layout from a char iterator.

Try to create a new layout from an unreliable char iterator.

Extend the layout with a new character.

Get the byte index mapping to the given position in the input string slice.

It is assumed that the input string slice matches the layout. Otherwise, the returned index may not point to an UTF8 character boundary nor even be in the slice bounds.

Get the sub slice of the input string matching the given span.

Trait Implementations

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.