pub struct SourceFile {
pub name: String,
pub source: String,
/* private fields */
}Expand description
Holds the source text for error reporting.
Fields§
§name: String§source: StringImplementations§
Source§impl SourceFile
impl SourceFile
Sourcepub fn new(name: impl Into<String>, source: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, source: impl Into<String>) -> Self
Create a new source file.
Sourcepub fn line(&self, line_number: u32) -> Option<&str>
pub fn line(&self, line_number: u32) -> Option<&str>
Extract a source line by 1-based line number.
Returns None if the line number is out of range.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Get the total number of lines.
Trait Implementations§
Source§impl Clone for SourceFile
impl Clone for SourceFile
Source§fn clone(&self) -> SourceFile
fn clone(&self) -> SourceFile
Returns a duplicate 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 moreAuto 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