#[non_exhaustive]pub struct Span<I> {
pub start: I,
pub end: I,
}
Expand description
A span in the source code, akin to start..end
so the end of the span is
exclusive.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.start: I
The start of the span.
end: I
The end of the span.
Implementations§
Source§impl<I> Span<I>
impl<I> Span<I>
Sourcepub const fn new(start: I, end: I) -> Self
pub const fn new(start: I, end: I) -> Self
Construct a new span.
§Examples
use syntree::Span;
let span = Span::new(4u32, 8u32);
assert_eq!(span.start, 4);
assert_eq!(span.end, 8);
Sourcepub const fn point(at: I) -> Selfwhere
I: Copy,
pub const fn point(at: I) -> Selfwhere
I: Copy,
Construct a span corresponding to the given point.
§Examples
use syntree::Span;
assert_eq!(Span::point(4u32), Span::new(4u32, 4u32));
Sourcepub fn join(&self, other: &Self) -> Self
pub fn join(&self, other: &Self) -> Self
Join the current span with another.
§Examples
use syntree::Span;
let a = Span::new(4u32, 8u32);
let b = Span::new(5u32, 9u32);
let span = a.join(&b);
assert_eq!(span.start, 4);
assert_eq!(span.end, 9);
assert_eq!(span, b.join(&a));
Sourcepub fn is_empty(&self) -> boolwhere
I: Eq,
pub fn is_empty(&self) -> boolwhere
I: Eq,
Test if the span is empty.
§Examples
use syntree::Span;
assert!(Span::new(0u32, 0u32).is_empty());
assert!(!Span::new(0u32, 10u32).is_empty());
Trait Implementations§
Source§impl<I: Ord> Ord for Span<I>
impl<I: Ord> Ord for Span<I>
Source§impl<I: PartialOrd> PartialOrd for Span<I>
impl<I: PartialOrd> PartialOrd for Span<I>
impl<I: Copy> Copy for Span<I>
impl<I: Eq> Eq for Span<I>
Auto Trait Implementations§
impl<I> Freeze for Span<I>where
I: Freeze,
impl<I> RefUnwindSafe for Span<I>where
I: RefUnwindSafe,
impl<I> Send for Span<I>where
I: Send,
impl<I> Sync for Span<I>where
I: Sync,
impl<I> Unpin for Span<I>where
I: Unpin,
impl<I> UnwindSafe for Span<I>where
I: UnwindSafe,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)