[−][src]Struct codespan::Span
Implementations
impl Span
[src]
pub fn new(start: impl Into<ByteIndex>, end: impl Into<ByteIndex>) -> Span
[src]
Create a new span from a starting and ending span.
pub const fn initial() -> Span
[src]
Gives an empty span at the start of a source.
pub fn from_str(s: &str) -> Span
[src]
Measure the span of a string.
use codespan::{ByteIndex, Span}; let span = Span::from_str("hello"); assert_eq!(span, Span::new(0, 5));
pub fn merge(self, other: Span) -> Span
[src]
Combine two spans by taking the start of the earlier span and the end of the later span.
Note: this will work even if the two spans are disjoint.
If this doesn't make sense in your application, you should handle it yourself.
In that case, you can use Span::disjoint
as a convenience function.
use codespan::Span; let span1 = Span::new(0, 4); let span2 = Span::new(10, 16); assert_eq!(Span::merge(span1, span2), Span::new(0, 16));
pub fn disjoint(self, other: Span) -> bool
[src]
A helper function to tell whether two spans do not overlap.
use codespan::Span; let span1 = Span::new(0, 4); let span2 = Span::new(10, 16); assert!(span1.disjoint(span2));
pub fn start(self) -> ByteIndex
[src]
Get the starting byte index.
use codespan::{ByteIndex, Span}; let span = Span::new(0, 4); assert_eq!(span.start(), ByteIndex::from(0));
pub fn end(self) -> ByteIndex
[src]
Get the ending byte index.
use codespan::{ByteIndex, Span}; let span = Span::new(0, 4); assert_eq!(span.end(), ByteIndex::from(4));
Trait Implementations
impl Clone for Span
[src]
impl Copy for Span
[src]
impl Debug for Span
[src]
impl Default for Span
[src]
impl Display for Span
[src]
impl Eq for Span
[src]
impl<I> From<Range<I>> for Span where
I: Into<ByteIndex>,
[src]
I: Into<ByteIndex>,
impl From<Span> for Range<usize>
[src]
impl From<Span> for Range<RawIndex>
[src]
impl Hash for Span
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Span
[src]
fn cmp(&self, other: &Span) -> 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 PartialEq<Span> for Span
[src]
impl PartialOrd<Span> for Span
[src]
fn partial_cmp(&self, other: &Span) -> Option<Ordering>
[src]
fn lt(&self, other: &Span) -> bool
[src]
fn le(&self, other: &Span) -> bool
[src]
fn gt(&self, other: &Span) -> bool
[src]
fn ge(&self, other: &Span) -> bool
[src]
impl StructuralEq for Span
[src]
impl StructuralPartialEq for Span
[src]
Auto Trait Implementations
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,