Struct gapbuf::RangeMut[][src]

pub struct RangeMut<'a, T: 'a> { /* fields omitted */ }

Mutable sub-range of GapBuffer.

Methods

impl<'a, T: 'a> RangeMut<'a, T>
[src]

Construct a new, empty RangeMut.

Methods from Deref<Target = Slice<T>>

Returns the number of elements in the GapBuffer.

Returns true if the GapBuffer contains no elements.

Returns a reference to an element at index or None if out of bounds.

Returns a mutable reference to an element at index or None if out of bounds.

Swaps two elements in the GapBuffer.

Arguments

  • a - The index of the first element
  • b - The index of the second element

Panics

Panics if a >= self.len() or b >= self.len().

Return a immutable sub-range of this Slice.

Panics

Panics if range is out of bounds.

Examples

let buf = gap_buffer![1, 2, 3, 4, 5];

let r1 = buf.range(1..);
assert_eq!(r1, [2, 3, 4, 5]);

let r2 = r1.range(1..3);
assert_eq!(r2, [3, 4]);

Return a mutable sub-range of this Slice.

Panics

Panics if range is out of bounds.

Examples

let mut buf = gap_buffer![1, 2, 3, 4, 5];
{
    let mut r = buf.range_mut(1..);
    assert_eq!(r, [2, 3, 4, 5]);
    r[0] = 0;
}
assert_eq!(buf, [1, 0, 3, 4, 5]);

Returns a pair of slices. First slice is before gap. Second slice is after gap.

Examples

let mut buf = gap_buffer![1, 2, 3, 4, 5];
buf.set_gap(2);
let (s1, s2) = buf.as_slices();
assert_eq!(s1, [1, 2]);
assert_eq!(s2, [3, 4, 5]);

Returns a pair of slices. First slice is before gap. Second slice is after gap.

Examples

let mut buf = gap_buffer![1, 2, 3, 4, 5];
buf.set_gap(2);
{
    let (mut s1, mut s2) = buf.as_mut_slices();
    s1[0] = 10;
    s2[0] = 11;
}
assert_eq!(buf, [10, 2, 11, 4, 5]);

Returns an iterator over the Slice.

Returns an iterator that allows modifying each value.

Trait Implementations

impl<'a, T: Hash + 'a> Hash for RangeMut<'a, T>
[src]

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

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

impl<'a, T> Deref for RangeMut<'a, T>
[src]

The resulting type after dereferencing.

Dereferences the value.

impl<'a, T> DerefMut for RangeMut<'a, T>
[src]

Mutably dereferences the value.

impl<'a, T> Default for RangeMut<'a, T>
[src]

Returns the "default value" for a type. Read more

impl<'a, T> Index<usize> for RangeMut<'a, T>
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<'a, T> IndexMut<usize> for RangeMut<'a, T>
[src]

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

impl<'a, T> Debug for RangeMut<'a, T> where
    T: Debug
[src]

Formats the value using the given formatter. Read more

impl<'a, T, S> PartialEq<S> for RangeMut<'a, T> where
    T: PartialEq,
    S: ?Sized,
    &'b S: IntoIterator<Item = &'b T>, 
[src]

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

This method tests for !=.

impl<'a, T: Eq> Eq for RangeMut<'a, T>
[src]

impl<'a, T, S> PartialOrd<S> for RangeMut<'a, T> where
    T: PartialOrd,
    S: ?Sized,
    &'b S: IntoIterator<Item = &'b T>, 
[src]

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

impl<'a, T: Ord> Ord for RangeMut<'a, T>
[src]

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

impl<'a, 'b, T> IntoIterator for &'a RangeMut<'b, T>
[src]

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

impl<'a, T> IntoIterator for &'a mut RangeMut<'a, T>
[src]

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

Auto Trait Implementations

impl<'a, T> Send for RangeMut<'a, T> where
    T: Send

impl<'a, T> Sync for RangeMut<'a, T> where
    T: Sync