[−][src]Struct gluon_base::pos::Span
A region of code in a source file
Implementations
impl<I> Span<I> where
I: Ord,
[src]
I: Ord,
pub fn new(start: I, end: I) -> Span<I>
[src]
Create a new span
use codespan::{ByteIndex, Span}; let span = Span::new(ByteIndex(3), ByteIndex(6)); assert_eq!(span.start(), ByteIndex(3)); assert_eq!(span.end(), ByteIndex(6));
start
and end
are reordered to maintain the invariant that start <= end
use codespan::{ByteIndex, Span}; let span = Span::new(ByteIndex(6), ByteIndex(3)); assert_eq!(span.start(), ByteIndex(3)); assert_eq!(span.end(), ByteIndex(6));
pub fn map<F, J>(self, f: F) -> Span<J> where
F: FnMut(I) -> J,
J: Ord,
[src]
F: FnMut(I) -> J,
J: Ord,
impl<I> Span<I>
[src]
pub const fn new_unchecked(start: I, end: I) -> Span<I>
[src]
Create a span like new
but does not check that start <= end
impl<I> Span<I>
[src]
impl<I> Span<I> where
I: Index,
[src]
I: Index,
pub fn subspan(
&self,
begin: <I as Index>::Offset,
end: <I as Index>::Offset
) -> Span<I>
[src]
&self,
begin: <I as Index>::Offset,
end: <I as Index>::Offset
) -> Span<I>
Makes a span from offsets relative to the start of this span.
pub fn from_offset(start: I, off: <I as Index>::Offset) -> Span<I>
[src]
Create a new span from a byte start and an offset
pub fn with_start(self, start: I) -> Span<I>
[src]
Return a new span with the low byte position replaced with the supplied byte position
use codespan::{ByteIndex, Span}; let span = Span::new(ByteIndex(3), ByteIndex(6)); assert_eq!(span.with_start(ByteIndex(2)), Span::new(ByteIndex(2), ByteIndex(6))); assert_eq!(span.with_start(ByteIndex(5)), Span::new(ByteIndex(5), ByteIndex(6))); assert_eq!(span.with_start(ByteIndex(7)), Span::new(ByteIndex(6), ByteIndex(7)));
pub fn with_end(self, end: I) -> Span<I>
[src]
Return a new span with the high byte position replaced with the supplied byte position
use codespan::{ByteIndex, Span}; let span = Span::new(ByteIndex(3), ByteIndex(6)); assert_eq!(span.with_end(ByteIndex(7)), Span::new(ByteIndex(3), ByteIndex(7))); assert_eq!(span.with_end(ByteIndex(5)), Span::new(ByteIndex(3), ByteIndex(5))); assert_eq!(span.with_end(ByteIndex(2)), Span::new(ByteIndex(2), ByteIndex(3)));
pub fn contains(self, other: Span<I>) -> bool
[src]
Return true if self
fully encloses other
.
use codespan::{ByteIndex, Span}; let a = Span::new(ByteIndex(5), ByteIndex(8)); assert_eq!(a.contains(a), true); assert_eq!(a.contains(Span::new(ByteIndex(6), ByteIndex(7))), true); assert_eq!(a.contains(Span::new(ByteIndex(6), ByteIndex(10))), false); assert_eq!(a.contains(Span::new(ByteIndex(3), ByteIndex(6))), false);
pub fn containment(self, pos: I) -> Ordering
[src]
Return Equal
if self
contains pos
, otherwise it returns Less
if pos
is before
start
or Greater
if pos
is after or at end
.
use codespan::{ByteIndex, Span}; use std::cmp::Ordering::*; let a = Span::new(ByteIndex(5), ByteIndex(8)); assert_eq!(a.containment(ByteIndex(4)), Less); assert_eq!(a.containment(ByteIndex(5)), Equal); assert_eq!(a.containment(ByteIndex(6)), Equal); assert_eq!(a.containment(ByteIndex(8)), Equal); assert_eq!(a.containment(ByteIndex(9)), Greater);
pub fn containment_exclusive(self, pos: I) -> Ordering
[src]
Return Equal
if self
contains pos
, otherwise it returns Less
if pos
is before
start
or Greater
if pos
is strictly after end
.
use codespan::{ByteIndex, Span}; use std::cmp::Ordering::*; let a = Span::new(ByteIndex(5), ByteIndex(8)); assert_eq!(a.containment_exclusive(ByteIndex(4)), Less); assert_eq!(a.containment_exclusive(ByteIndex(5)), Equal); assert_eq!(a.containment_exclusive(ByteIndex(6)), Equal); assert_eq!(a.containment_exclusive(ByteIndex(8)), Greater); assert_eq!(a.containment_exclusive(ByteIndex(9)), Greater);
pub fn to(self, end: Span<I>) -> Span<I>
[src]
Return a Span
that would enclose both self
and end
.
self ~~~~~~~
end ~~~~~~~~
returns ~~~~~~~~~~~~~~~~~~~~~~~
use codespan::{ByteIndex, Span}; let a = Span::new(ByteIndex(2), ByteIndex(5)); let b = Span::new(ByteIndex(10), ByteIndex(14)); assert_eq!(a.to(b), Span::new(ByteIndex(2), ByteIndex(14)));
pub fn between(self, end: Span<I>) -> Span<I>
[src]
Return a Span
between the end of self
to the beginning of end
.
self ~~~~~~~
end ~~~~~~~~
returns ~~~~~~~~~
use codespan::{ByteIndex, Span}; let a = Span::new(ByteIndex(2), ByteIndex(5)); let b = Span::new(ByteIndex(10), ByteIndex(14)); assert_eq!(a.between(b), Span::new(ByteIndex(5), ByteIndex(10)));
pub fn until(self, end: Span<I>) -> Span<I>
[src]
Return a Span
between the beginning of self
to the beginning of end
.
self ~~~~~~~
end ~~~~~~~~
returns ~~~~~~~~~~~~~~~~
use codespan::{ByteIndex, Span}; let a = Span::new(ByteIndex(2), ByteIndex(5)); let b = Span::new(ByteIndex(10), ByteIndex(14)); assert_eq!(a.until(b), Span::new(ByteIndex(2), ByteIndex(10)));
Trait Implementations
impl<I> Clone for Span<I> where
I: Clone,
[src]
I: Clone,
impl<I> Copy for Span<I> where
I: Copy,
[src]
I: Copy,
impl<I> Debug for Span<I> where
I: Debug,
[src]
I: Debug,
impl<I> Default for Span<I> where
I: Default,
[src]
I: Default,
impl<I> Display for Span<I> where
I: Display,
[src]
I: Display,
impl<I> Eq for Span<I> where
I: Eq,
[src]
I: Eq,
impl<I> Ord for Span<I> where
I: Ord,
[src]
I: Ord,
fn cmp(&self, other: &Span<I>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<I> PartialEq<Span<I>> for Span<I> where
I: PartialEq<I>,
[src]
I: PartialEq<I>,
impl<I> PartialOrd<Span<I>> for Span<I> where
I: PartialOrd<I>,
[src]
I: PartialOrd<I>,
fn partial_cmp(&self, other: &Span<I>) -> Option<Ordering>
[src]
fn lt(&self, other: &Span<I>) -> bool
[src]
fn le(&self, other: &Span<I>) -> bool
[src]
fn gt(&self, other: &Span<I>) -> bool
[src]
fn ge(&self, other: &Span<I>) -> bool
[src]
impl<I> StructuralEq for Span<I>
[src]
impl<I> StructuralPartialEq for Span<I>
[src]
Auto Trait Implementations
impl<I> RefUnwindSafe for Span<I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
impl<I> Send for Span<I> where
I: Send,
I: Send,
impl<I> Sync for Span<I> where
I: Sync,
I: Sync,
impl<I> Unpin for Span<I> where
I: Unpin,
I: Unpin,
impl<I> UnwindSafe for Span<I> where
I: UnwindSafe,
I: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
[src]
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,