Struct tvix_eval::SourceCode
source · pub struct SourceCode(Rc<RefCell<CodeMap>>);
Expand description
Tracks all source code in a Tvix 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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