pub struct SourceMap {
pub base_uri: String,
pub text: String,
pub line_starts: Vec<usize>,
}Expand description
Per-document source mapping for line/column resolution
Owns the source text buffer and line start index.
Use build_line_starts() to construct the line index once.
Fields§
§base_uri: String§text: String§line_starts: Vec<usize>Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn locate(&self, offset: usize) -> SourceLocation
pub fn locate(&self, offset: usize) -> SourceLocation
Convert byte offset to line/column location
Returns 1-based line and column numbers. Column is counted in UTF-8 characters, not bytes.
Sourcepub fn get_text(&self, span: &SourceSpan) -> Option<&str>
pub fn get_text(&self, span: &SourceSpan) -> Option<&str>
Get source text for a span (returns None if span invalid)
Sourcepub fn into_compact(self) -> CompactSourceMap
pub fn into_compact(self) -> CompactSourceMap
Convert to compact source map (drops text, keeps line_starts)
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 UnsafeUnpin 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