Struct pest::Span [] [src]

pub struct Span<'i> { /* fields omitted */ }

A struct of a span over a &str. It is created from either two Positions or from a Pair.

Methods

impl<'i> Span<'i>
[src]

[src]

Returns the Span's start byte position as a usize.

Examples

let input = "ab";
let start = Position::from_start(input);
let end = start.clone().match_string("ab").unwrap();
let span = start.span(&end);

assert_eq!(span.start(), 0);

[src]

Returns the Span's end byte position as a usize.

Examples

let input = "ab";
let start = Position::from_start(input);
let end = start.clone().match_string("ab").unwrap();
let span = start.span(&end);

assert_eq!(span.end(), 2);

[src]

Returns the Span's start Position.

Examples

let input = "ab";
let start = Position::from_start(input);
let end = start.clone().match_string("ab").unwrap();
let span = start.clone().span(&end);

assert_eq!(span.start_pos(), start);

[src]

Returns the Span's end Position.

Examples

let input = "ab";
let start = Position::from_start(input);
let end = start.clone().match_string("ab").unwrap();
let span = start.span(&end);

assert_eq!(span.end_pos(), end);

[src]

Splits the Span into a pair of Positions.

Examples

let input = "ab";
let start = Position::from_start(input);
let end = start.clone().match_string("ab").unwrap();
let span = start.clone().span(&end);

assert_eq!(span.split(), (start, end));

[src]

Captures a slice from the &str defined by the Span.

Examples

let input = "abc";
let start = Position::from_start(input).skip(1).unwrap();
let end = start.clone().match_string("b").unwrap();
let span = start.span(&end);

assert_eq!(span.as_str(), "b");

Trait Implementations

impl<'i> Debug for Span<'i>
[src]

[src]

Formats the value using the given formatter.

impl<'i> Clone for Span<'i>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'i> PartialEq for Span<'i>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<'i> Eq for Span<'i>
[src]

impl<'i> PartialOrd for Span<'i>
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<'i> Ord for Span<'i>
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl<'i> Hash for Span<'i>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

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