pub struct Span { /* private fields */ }Expand description
Spans can be created directly using Span::new, or by using the Spanned trait to
access the underlying Span of a type.
use quoth::*;
use std::rc::Rc;
let span = Span::new(Rc::new(Source::from_str("Hello, world!")), 0..5);Spans can be joined together using the Span::join method, which will return a new
Span that encompasses both of the original spans. This can be useful for combining
spans that were generated from different parts of the same source.
use quoth::*;
use std::rc::Rc;
let source = Rc::new(Source::from_str("Hello, world!"));
let span1 = Span::new(source.clone(), 0..5);
let span2 = Span::new(source.clone(), 7..12);
let encompassing_span = span1.join(&span2).unwrap();
assert_eq!(encompassing_span.source_text(), "Hello, world");Implementations§
Source§impl Span
impl Span
Sourcepub fn source_text(&self) -> IndexedSlice<'_>
pub fn source_text(&self) -> IndexedSlice<'_>
Sourcepub fn source_path(&self) -> Option<&Path>
pub fn source_path(&self) -> Option<&Path>
Sourcepub fn byte_range(&self) -> &Range<usize>
pub fn byte_range(&self) -> &Range<usize>
Sourcepub fn source_lines(
&self,
) -> impl Iterator<Item = (IndexedSlice<'_>, Range<usize>)> + '_
pub fn source_lines( &self, ) -> impl Iterator<Item = (IndexedSlice<'_>, Range<usize>)> + '_
Trait Implementations§
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl !Send for Span
impl !Sync for Span
impl Freeze for Span
impl RefUnwindSafe for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
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