pub struct SourceFile {
pub name: FileName,
pub src: String,
pub absolute_start: u32,
pub absolute_end: u32,
}
Expand description
A single source in the SourceMap
.
Fields§
§name: FileName
The name of the file that the source came from.
src: String
The complete source code.
absolute_start: u32
The start position of this source in the SourceMap
.
absolute_end: u32
The end position of this source in the SourceMap
.
Implementations§
Source§impl SourceFile
impl SourceFile
Sourcepub fn relative_offset(&self, absolute_offset: u32) -> u32
pub fn relative_offset(&self, absolute_offset: u32) -> u32
Converts an absolute offset to a file-relative offset
Sourcepub fn contents_of_span(&self, span: Span) -> &str
pub fn contents_of_span(&self, span: Span) -> &str
Returns contents of a span
assumed to be within the given file.
pub fn line_col(&self, absolute_offset: u32) -> (u32, u32)
pub fn line_contents(&self, span: Span) -> LineContents<'_>
Auto Trait Implementations§
impl Freeze for SourceFile
impl RefUnwindSafe for SourceFile
impl Send for SourceFile
impl Sync for SourceFile
impl Unpin for SourceFile
impl UnwindSafe for SourceFile
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> 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