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 SourceFilepub 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 SourceFilefn default() -> SourceFile[src]
fn default() -> SourceFileReturns the "default value" for a type. Read more
impl Debug for SourceFile[src]
impl Debug for SourceFilefn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Clone for SourceFile[src]
impl Clone for SourceFilefn clone(&self) -> SourceFile[src]
fn clone(&self) -> SourceFileReturns 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 SourceFileimpl PartialEq for SourceFile[src]
impl PartialEq for SourceFilefn eq(&self, other: &SourceFile) -> bool[src]
fn eq(&self, other: &SourceFile) -> boolThis 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) -> boolThis method tests for !=.
impl Ord for SourceFile[src]
impl Ord for SourceFilefn cmp(&self, other: &SourceFile) -> Ordering[src]
fn cmp(&self, other: &SourceFile) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl PartialOrd for SourceFile[src]
impl PartialOrd for SourceFilefn 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) -> boolThis 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) -> boolThis 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) -> boolThis 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) -> boolThis 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 SourceFileAuto Trait Implementations
impl Send for SourceFile
impl Send for SourceFileimpl Sync for SourceFile
impl Sync for SourceFile