regex_automata Struct Span Copy item path Source pub struct Span {
pub start: usize ,
pub end: usize ,
}
Expand description A representation of a span reported by a regex engine.
A span corresponds to the starting and ending byte offsets of a
contiguous region of bytes. The starting offset is inclusive while the
ending offset is exclusive. That is, a span is a half-open interval.
A span is used to report the offsets of a match, but it is also used to
convey which region of a haystack should be searched via routines like
Input::span
.
This is basically equivalent to a std::ops::Range<usize>
, except this
type implements Copy
which makes it more ergonomic to use in the context
of this crate. Like a range, this implements Index
for [u8]
and str
,
and IndexMut
for [u8]
. For convenience, this also impls From<Range>
,
which means things like Span::from(5..10)
work.
The start offset of the span, inclusive.
The end offset of the span, exclusive.
Returns this span as a range.
Returns true when this span is empty. That is, when start >= end
.
Returns the length of this span.
This returns 0
in precisely the cases that is_empty
returns true
.
Returns true when the given offset is contained within this span.
Note that an empty span contains no offsets and will always return
false.
Returns a new span with offset
added to this span’s start
and end
values.
Performs copy-assignment from
source
.
Read more Formats the value using the given formatter.
Read more Converts to this type from the input type.
Converts to this type from the input type.
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 Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit
)
Performs copy-assignment from
self
to
dst
.
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.