Struct range::Range
[−]
[src]
pub struct Range<T = ()> { pub offset: usize, pub length: usize, pub data: T, }
A representation of a range
The type parameter is used to wrap data related to the range.
Fields
offset: usize
The range offset
length: usize
The range length
data: T
The data described within the range.
Methods
impl Range
[src]
fn new(offset: usize, length: usize) -> Range
Creates a new Range
fn wrap<T>(self, data: T) -> Range<T>
Wraps some data in the range.
fn empty(offset: usize) -> Range
Creates an empty range with an offset.
fn shrink_n(&self, n: usize) -> Option<Range>
Shrinks range at both ends with n
items.
fn shrink(&self) -> Option<Range>
Shrinks range at both ends with 1 item.
fn intersect(&self, other: &Range) -> Option<Range>
Intersects a range with another, where ends are excluded.
fn ends_intersect(&self, other: &Range) -> Option<Range>
Intersects a range with another, where ends are included.
impl<T> Range<T>
[src]
fn is_empty(&self) -> bool
Returns true if range is empty
fn next_offset(&self) -> usize
Returns the next offset
fn iter(&self) -> Range<usize>
Returns a range iterator.
fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Range<U>
Maps from some data to another.
fn range(&self) -> Range
Returns range information without the data.
fn unwrap(self) -> T
Unwraps the data.
fn decouple(self) -> (Range, T)
Decouples range and data.
Trait Implementations
impl<T: Copy> Copy for Range<T>
[src]
impl<T: Clone> Clone for Range<T>
[src]
fn clone(&self) -> Range<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: PartialEq> PartialEq for Range<T>
[src]
fn eq(&self, __arg_0: &Range<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Range<T>) -> bool
This method tests for !=
.
impl<T: Eq> Eq for Range<T>
[src]
impl<T: Hash> Hash for Range<T>
[src]
fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more