pub struct SourceFile {
pub path: String,
pub source: String,
pub byte_len: usize,
}Expand description
A parsed source file with its path and content.
Wraps the raw source text together with metadata that is useful for diagnostics and IDE integration.
Fields§
§path: StringPath to the source file (may be virtual, e.g., <repl>).
source: StringThe raw source text.
byte_len: usizeLength of the source in bytes.
Implementations§
Source§impl SourceFile
impl SourceFile
Sourcepub fn new(path: impl Into<String>, source: impl Into<String>) -> Self
pub fn new(path: impl Into<String>, source: impl Into<String>) -> Self
Create a new source file from a path and source string.
Sourcepub fn virtual_(source: impl Into<String>) -> Self
pub fn virtual_(source: impl Into<String>) -> Self
Create a virtual source file (e.g., for REPL input).
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Returns the number of lines in the source file.
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 UnsafeUnpin 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