pub struct CodeMap(/* private fields */);
Expand description
A data structure recording a source code file for position lookup.
Implementations§
source§impl CodeMap
impl CodeMap
pub fn empty_static() -> &'static CodeMap
pub fn full_span(&self) -> Span
sourcepub fn file_span(&self, span: Span) -> FileSpan
pub fn file_span(&self, span: Span) -> FileSpan
Gets the file and its line and column ranges represented by a Span
.
pub fn byte_at(&self, pos: Pos) -> u8
sourcepub fn find_line(&self, pos: Pos) -> usize
pub fn find_line(&self, pos: Pos) -> usize
Gets the line number of a Pos.
The lines are 0-indexed (first line is numbered 0)
Panics if pos
is not within this file’s span.
sourcepub fn source_span(&self, span: Span) -> &str
pub fn source_span(&self, span: Span) -> &str
Gets the source text of a Span.
Panics if span
is not entirely within this file.
sourcepub fn line_span(&self, line: usize) -> Span
pub fn line_span(&self, line: usize) -> Span
Like line_span_opt
but panics if the line number is out of range.
sourcepub fn line_span_opt(&self, line: usize) -> Option<Span>
pub fn line_span_opt(&self, line: usize) -> Option<Span>
Gets the span representing a line by line number.
The line number is 0-indexed (first line is numbered 0). The returned span includes the line terminator.
Returns None if the number if out of range.
pub fn resolve_span(&self, span: Span) -> ResolvedSpan
sourcepub fn source_line(&self, line: usize) -> &str
pub fn source_line(&self, line: usize) -> &str
Gets the source text of a line.
The string returned does not include the terminating \r or \n characters.
Panics if the line number is out of range.
pub fn source_line_at_pos(&self, pos: Pos) -> &str
Trait Implementations§
source§impl Allocative for CodeMap
impl Allocative for CodeMap
impl Eq for CodeMap
Auto Trait Implementations§
impl RefUnwindSafe for CodeMap
impl Send for CodeMap
impl Sync for CodeMap
impl Unpin for CodeMap
impl UnwindSafe for CodeMap
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.