pub struct Source { /* private fields */ }Expand description
One immutable source snapshot shared by every span into it.
Implementations§
Source§impl Source
impl Source
Sourcepub fn new(text: impl Into<Arc<str>>) -> Arc<Self> ⓘ
pub fn new(text: impl Into<Arc<str>>) -> Arc<Self> ⓘ
Creates an ordinary source file with a fresh compact identity.
Sourcepub fn synthetic(text: impl Into<Arc<str>>) -> Arc<Self> ⓘ
pub fn synthetic(text: impl Into<Arc<str>>) -> Arc<Self> ⓘ
Creates source text for syntax constructed outside an input file.
Sourcepub fn with_file(file: File, text: impl Into<Arc<str>>) -> Arc<Self> ⓘ
pub fn with_file(file: File, text: impl Into<Arc<str>>) -> Arc<Self> ⓘ
Creates a source snapshot with an explicitly selected source kind.
Sourcepub fn line_column(&self, offset: Offset) -> Option<LineColumn>
pub fn line_column(&self, offset: Offset) -> Option<LineColumn>
Converts a byte boundary into a one-based line and character column.
Returns None when offset lies outside this snapshot or inside a
multi-byte UTF-8 character.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnsafeUnpin 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