pub struct SourceMap { /* private fields */ }Implementations§
Source§impl SourceMap
impl SourceMap
pub fn new() -> SourceMap
pub fn add( &mut self, name: impl Into<String>, text: impl Into<String>, ) -> FileId
pub fn name(&self, file: FileId) -> &str
pub fn text(&self, file: FileId) -> &str
pub fn snippet(&self, span: Span) -> &str
Sourcepub fn line_col(&self, file: FileId, offset: u32) -> (usize, usize)
pub fn line_col(&self, file: FileId, offset: u32) -> (usize, usize)
1-based line and column (column counted in characters, not bytes).
A span from a file this map does not hold reports 1:1 rather than panicking. That is a
compiler defect wherever it happens — a diagnostic that cannot be located is a diagnostic
nobody can act on — but the failure belongs in the message, not in a crash during rendering.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SourceMap
impl RefUnwindSafe for SourceMap
impl Send for SourceMap
impl Sync for SourceMap
impl Unpin for SourceMap
impl UnwindSafe for SourceMap
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