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§
Sourcefn new(src: Arc<SourceFile>) -> Self
fn new(src: Arc<SourceFile>) -> Self
Create a new implementation of this source from the given SourceFile
Sourcefn read(&mut self) -> Option<(SourceIndex, char)>
fn read(&mut self) -> Option<(SourceIndex, char)>
Read the next character from the source
Sourcefn peek(&mut self) -> Option<(SourceIndex, char)>
fn peek(&mut self) -> Option<(SourceIndex, char)>
Peek the next character from the source
Sourcefn span(&self) -> SourceSpan
fn span(&self) -> SourceSpan
Get a SourceSpan corresponding to the entire source file
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.