[][src]Struct source_span::lazy::Buffer

pub struct Buffer<I: Iterator<Item = Result<char>>> { /* fields omitted */ }

Lazy string buffer that fills up on demand.

The lazy::Buffer wraps aroung a char iterator. It can be itself used as a char iterator, or as a Buffer to access an arbitrary fragment of the input source stream.

Methods

impl<I: Iterator<Item = Result<char>>> Buffer<I>[src]

pub fn new(input: I, position: Position) -> Buffer<I>[src]

Create a new empty buffer starting at the given position.

pub fn span(&self) -> Span[src]

Get the span of the entire buffered data.

pub fn index_at(&self, pos: Position) -> Option<Result<usize>>[src]

Get the index of the char at the given cursor position if it is in the buffer. If it is not in the buffer but after the buffered content, the input stream will be read until the buffer span includes the given position.

Returns None if the given position if previous to the buffer start positions, if the source stream ends before the given position, or if the line at the given position is shorter than the given position column.

pub fn at(&self, pos: Position) -> Option<Result<char>>[src]

Get the char at the given position if it is in the buffer. If it is not in the buffer but after the buffered content, the input stream will be read until the buffer span includes the given position.

Returns None if the given position if previous to the buffer start positions, if the source stream ends before the given position, or if the line at the given position is shorter than the given position column.

Important traits for Iter<'b, I>
pub fn iter(&self) -> Iter<I>[src]

Returns an iterator through the characters of the buffer from the begining of it.

When it reaches the end of the buffer, the buffer will start reading from the source stream.

Important traits for Iter<'b, I>
pub fn iter_from(&self, pos: Position) -> Iter<I>[src]

Returns an iterator through the characters of the buffer from the given position.

If the input position precedes the buffer start position, then it will start from the buffer start position. When it reaches the end of the buffer, the buffer will start reading from the source stream.

Important traits for Iter<'b, I>
pub fn iter_span(&self, span: Span) -> Iter<I>[src]

Returns an iterator through the characters of the buffer in the given span.

If the input start position precedes the buffer start position, then it will start from the buffer start position. When it reaches the end of the buffer, the buffer will start reading from the source stream.

Auto Trait Implementations

impl<I> !Sync for Buffer<I>

impl<I> Send for Buffer<I> where
    I: Send

impl<I> Unpin for Buffer<I> where
    I: Unpin

impl<I> !RefUnwindSafe for Buffer<I>

impl<I> !UnwindSafe for Buffer<I>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]