Trait Source

Source
pub trait Source: Sized {
    // Required methods
    fn new(src: Arc<SourceFile>) -> Self;
    fn read(&mut self) -> Option<(SourceIndex, char)>;
    fn peek(&mut self) -> Option<(SourceIndex, char)>;
    fn span(&self) -> SourceSpan;
    fn slice(&self, span: impl Into<Range<usize>>) -> &str;
}
Expand description

Source is an abstraction for files which are read via [Scanner]

Required Methods§

Source

fn new(src: Arc<SourceFile>) -> Self

Create a new implementation of this source from the given SourceFile

Source

fn read(&mut self) -> Option<(SourceIndex, char)>

Read the next character from the source

Source

fn peek(&mut self) -> Option<(SourceIndex, char)>

Peek the next character from the source

Source

fn span(&self) -> SourceSpan

Get a SourceSpan corresponding to the entire source file

Source

fn slice(&self, span: impl Into<Range<usize>>) -> &str

Get a string slice of the underlying source content from the given range

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§