pub struct Span { /* private fields */ }
Expand description

Range of bytes in a source file.

This is very similar to the Range<usize> type unless it is not an iterator and implements the Copy trait.

Implementations

Creates a new Span by providing the index of its starting byte (included) and ending byte (excluded).

If the end position is lower than the start position, then the start position is used as ending position instead.

Size of the span in bytes.

Checks if the span is empty.

Returns true if the start position is equal to the end position, and false otherwise. The end position can never be lower than the start position.

Returns the index of the first byte in the span.

Returns the index of the first byte after the span.

This can never be lower than Self::start.

Returns the range of bytes inside the span.

Checks if the given byte index if included in the span.

Sets the index of the first byte in the span.

If the end position of the span is lower that start, then it is also changed into start.

Sets the index of the first byte after the span.

If end is lower that the start position, the start position is used instead.

Computes the union of two spans.

If the two spans do not overlap, all the positions in between will be included in the resulting span.

Extend this span to include other.

This is the in-place version of union.

Computes the intersection of two spans.

If the two spans do not overlap, then the empty span located at the start of the most advanced span (maximum of the start of the two spans) is returned.

Clear the span by moving its start position to its end position.

Return the “next” span: the empty span starting at the end of this one.

Push count bytes to the span.

Move its end position by count.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

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

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

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

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

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.