[][src]Struct codespan::Span

pub struct Span { /* fields omitted */ }

Methods

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 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 first span and the end of the other span.

use codespan::{ByteIndex, 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 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]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for Span[src]

impl Ord for Span[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl PartialOrd<Span> for Span[src]

impl<I> From<Range<I>> for Span where
    I: Into<ByteIndex>, 
[src]

impl Copy for Span[src]

impl Eq for Span[src]

impl PartialEq<Span> for Span[src]

impl Hash for Span[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Display for Span[src]

impl Debug for Span[src]

Auto Trait Implementations

impl Unpin for Span

impl Sync for Span

impl Send for Span

impl UnwindSafe for Span

impl RefUnwindSafe for Span

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]