Struct sourcefile::SourceFile [−][src]
pub struct SourceFile { pub contents: String, // some fields omitted }
A concatenated string of files, with sourcemap information.
Fields
contents: String
The full contents of all the files
Methods
impl SourceFile
[src]
impl SourceFile
pub fn add_file(
self,
filename: impl AsRef<Path>
) -> Result<Self, Error>
[src]
pub fn add_file(
self,
filename: impl AsRef<Path>
) -> Result<Self, Error>
Concatenate a file to the end of contents
, and record info needed to resolve spans.
If the last line doesn't end with a newline character, it will still be a 'line' for the purposes of this calcuation.
Consumes self
because the structure would be inconsistent after an error.
pub fn resolve_offset<'a>(&'a self, offset: usize) -> Option<Position<'a>>
[src]
pub fn resolve_offset<'a>(&'a self, offset: usize) -> Option<Position<'a>>
Get the file, line, and col position of a byte offset.
Panics
This function will panic if offset
is not on a character boundary.
pub fn resolve_offset_span<'a>(
&'a self,
start: usize,
end: usize
) -> Option<Span<'a>>
[src]
pub fn resolve_offset_span<'a>(
&'a self,
start: usize,
end: usize
) -> Option<Span<'a>>
Get the file, line, and col position of each end of a span
Trait Implementations
impl Default for SourceFile
[src]
impl Default for SourceFile
fn default() -> SourceFile
[src]
fn default() -> SourceFile
Returns the "default value" for a type. Read more
impl Debug for SourceFile
[src]
impl Debug for SourceFile
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for SourceFile
[src]
impl Clone for SourceFile
fn clone(&self) -> SourceFile
[src]
fn clone(&self) -> SourceFile
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Eq for SourceFile
[src]
impl Eq for SourceFile
impl PartialEq for SourceFile
[src]
impl PartialEq for SourceFile
fn eq(&self, other: &SourceFile) -> bool
[src]
fn eq(&self, other: &SourceFile) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &SourceFile) -> bool
[src]
fn ne(&self, other: &SourceFile) -> bool
This method tests for !=
.
impl Ord for SourceFile
[src]
impl Ord for SourceFile
fn cmp(&self, other: &SourceFile) -> Ordering
[src]
fn cmp(&self, other: &SourceFile) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl PartialOrd for SourceFile
[src]
impl PartialOrd for SourceFile
fn partial_cmp(&self, other: &SourceFile) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &SourceFile) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &SourceFile) -> bool
[src]
fn lt(&self, other: &SourceFile) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &SourceFile) -> bool
[src]
fn le(&self, other: &SourceFile) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &SourceFile) -> bool
[src]
fn gt(&self, other: &SourceFile) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &SourceFile) -> bool
[src]
fn ge(&self, other: &SourceFile) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Hash for SourceFile
[src]
impl Hash for SourceFile
Auto Trait Implementations
impl Send for SourceFile
impl Send for SourceFile
impl Sync for SourceFile
impl Sync for SourceFile