Struct range::Range [] [src]

pub struct Range<T = ()> {
    pub offset: usize,
    pub length: usize,
    // some fields omitted
}

A representation of a range

The type parameter is used for extra type safety to avoid using a range for the wrong kind of action. This can be a specific action to be performed on the range, for example Range<AddTo<T>>.

Fields

offset: usize

The range offset

length: usize

The range length

Methods

impl<T> Range<T>
[src]

fn new(offset: usize, length: usize) -> Range<T>

Creates a new Range

fn cast<U>(self) -> Range<U>

Casts a range into another type.

fn empty(offset: usize) -> Range<T>

Creates an empty range with an offset.

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 shrink_n(&self, n: usize) -> Option<Range<T>>

Shrinks range at both ends with n items.

fn shrink(&self) -> Option<Range<T>>

Shrinks range at both ends with 1 item.

fn intersect(&self, other: &Range<T>) -> Option<Range<T>>

Intersects a range with another, where ends are excluded.

fn ends_intersect(&self, other: &Range<T>) -> Option<Range<T>>

Intersects a range with another, where ends are included.

Trait Implementations

impl<T: Debug> Debug for Range<T>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<T: Hash> Hash for Range<T>
[src]

fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)

Feeds this value into the state given, updating the hasher as necessary.

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

Feeds a slice of this type into the state provided.

impl<T: Eq> Eq for Range<T>
[src]

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: 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: Copy> Copy for Range<T>
[src]