pub struct SourceCode(Rc<RefCell<CodeMap>>);Expand description
Tracks all source code in a Snix evaluation for accurate error reporting.
Tuple Fields§
§0: Rc<RefCell<CodeMap>>Implementations§
Source§impl SourceCode
 
impl SourceCode
Sourcefn codemap_mut(&self) -> RefMut<'_, CodeMap>
 
fn codemap_mut(&self) -> RefMut<'_, CodeMap>
Access a writable reference to the codemap.
Sourcepub fn add_file(&self, name: String, code: String) -> Arc<File>
 
pub fn add_file(&self, name: String, code: String) -> Arc<File>
Add a file to the codemap. The returned Arc is managed by the codemap internally and can be used like a normal reference.
Sourcepub fn get_line(&self, span: Span) -> usize
 
pub fn get_line(&self, span: Span) -> usize
Retrieve the line number of the given span. If it spans multiple lines, the first line will be returned.
Sourcepub fn source_slice(&self, span: Span) -> Ref<'_, str>
 
pub fn source_slice(&self, span: Span) -> Ref<'_, str>
Returns the literal source slice of the given span.
Trait Implementations§
Source§impl Clone for SourceCode
 
impl Clone for SourceCode
Source§fn clone(&self) -> SourceCode
 
fn clone(&self) -> SourceCode
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moreSource§impl Debug for SourceCode
 
impl Debug for SourceCode
Auto Trait Implementations§
impl Freeze for SourceCode
impl !RefUnwindSafe for SourceCode
impl !Send for SourceCode
impl !Sync for SourceCode
impl Unpin for SourceCode
impl !UnwindSafe for SourceCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more