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
impl<M: Metrics> Layout<M>
[src]
impl<M: Metrics> Layout<M>
[src]pub fn from<Chars: Iterator<Item = char>>(chars: Chars, metrics: M) -> Layout<M>
[src]
pub fn from<Chars: Iterator<Item = char>>(chars: Chars, metrics: M) -> Layout<M>
[src]Create a new layout from a char
iterator.
pub fn try_from<E, Chars: Iterator<Item = Result<char, E>>>(
chars: Chars,
metrics: M
) -> Result<Layout<M>, E>
[src]
pub fn try_from<E, Chars: Iterator<Item = Result<char, E>>>(
chars: Chars,
metrics: M
) -> Result<Layout<M>, E>
[src]Try to create a new layout from an unreliable char
iterator.
pub fn byte_index(&self, str: &str, position: Position) -> Option<usize>
[src]
pub fn byte_index(&self, str: &str, position: Position) -> Option<usize>
[src]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.
pub fn span_slice<'a>(&self, str: &'a str, span: Span) -> &'a str
[src]
pub fn span_slice<'a>(&self, str: &'a str, span: Span) -> &'a str
[src]Get the sub slice of the input string matching the given span.
Trait Implementations
impl<M: Metrics> Extend<char> for Layout<M>
[src]
impl<M: Metrics> Extend<char> for Layout<M>
[src]fn extend<Chars: IntoIterator<Item = char>>(&mut self, chars: Chars)
[src]
fn extend<Chars: IntoIterator<Item = char>>(&mut self, chars: Chars)
[src]Extends a collection with the contents of an iterator. Read more
fn extend_one(&mut self, item: A)
[src]
fn extend_one(&mut self, item: A)
[src]🔬 This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
fn extend_reserve(&mut self, additional: usize)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]🔬 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
impl<M> RefUnwindSafe for Layout<M> where
M: RefUnwindSafe,
M: RefUnwindSafe,
impl<M> Send for Layout<M> where
M: Send,
M: Send,
impl<M> Sync for Layout<M> where
M: Sync,
M: Sync,
impl<M> Unpin for Layout<M> where
M: Unpin,
M: Unpin,
impl<M> UnwindSafe for Layout<M> where
M: UnwindSafe,
M: UnwindSafe,