pub struct SpanLocation {
line: usize,
char_offset: usize,
}Expand description
A struct used to represent Span’s index field
as line and character offset indices. Meant for logging purposes.
line and char_offset are 0-based indices.
Fields§
§line: usize§char_offset: usizeImplementations§
Source§impl SpanLocation
impl SpanLocation
Sourcepub fn new(line: usize, char_offset: usize) -> Self
pub fn new(line: usize, char_offset: usize) -> Self
Constructs a SpanLocation with provided
line and char_offset indices.
Sourcepub fn from_index(source: &str, index: usize) -> Result<Self, SpanError>
pub fn from_index(source: &str, index: usize) -> Result<Self, SpanError>
Constructs a SpanLocation with a provided
source and index.
§Error Handling
If index is out of bounds of source,
this method will return SpanError::OutOfBounds.
Sourcepub fn from_index_unchecked(source: &str, index: usize) -> Self
pub fn from_index_unchecked(source: &str, index: usize) -> Self
Constructs a SpanLocation with a provided
source and index
§Panics
This method panics if index is out of the
bounds of source
Sourcepub fn char_offset(&self) -> usize
pub fn char_offset(&self) -> usize
Returns char_offset.
Trait Implementations§
Source§impl Clone for SpanLocation
impl Clone for SpanLocation
Source§fn clone(&self) -> SpanLocation
fn clone(&self) -> SpanLocation
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpanLocation
impl Debug for SpanLocation
Source§impl Display for SpanLocation
impl Display for SpanLocation
Source§impl Ord for SpanLocation
impl Ord for SpanLocation
Source§impl PartialEq for SpanLocation
impl PartialEq for SpanLocation
Source§impl PartialOrd for SpanLocation
impl PartialOrd for SpanLocation
impl Copy for SpanLocation
impl Eq for SpanLocation
impl StructuralPartialEq for SpanLocation
Auto Trait Implementations§
impl Freeze for SpanLocation
impl RefUnwindSafe for SpanLocation
impl Send for SpanLocation
impl Sync for SpanLocation
impl Unpin for SpanLocation
impl UnwindSafe for SpanLocation
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes