pub struct Source { /* private fields */ }Expand description
Represents source text that can be indexed into to define individual Spans.
Implementations§
Source§impl Source
impl Source
Sourcepub fn source_text(&self) -> IndexedSlice<'_>
pub fn source_text(&self) -> IndexedSlice<'_>
Returns the underlying text of this Source, with original formatting.
Sourcepub fn from_indexed_string(text: IndexedString) -> Self
pub fn from_indexed_string(text: IndexedString) -> Self
Creates a new Source from an IndexedString.
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self, Error>
Reads the contents of a file and returns a Source with the file’s text.
Since no parsing is done at this stage, only IO or encoding errors will be returned, regardless of the validity of the syntax in the file.
Sourcepub fn set_path(&mut self, path: Option<impl AsRef<Path>>)
pub fn set_path(&mut self, path: Option<impl AsRef<Path>>)
Sets the path of the file that this Source was read from.
Sourcepub fn source_path(&self) -> Option<&Path>
pub fn source_path(&self) -> Option<&Path>
Returns the path of the file that this Source was read from, if it was read from a file.
Trait Implementations§
impl Eq for Source
impl StructuralPartialEq for Source
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
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