[−][src]Struct gapbuf::RangeMut
Mutable sub-range of GapBuffer
.
This struct is created by Slice::range_mut
.
Implementations
impl<'a, T: 'a> RangeMut<'a, T>
[src]
Methods from Deref<Target = Slice<T>>
pub fn len(&self) -> usize
[src]
Returns the number of elements in the GapBuffer.
pub fn is_empty(&self) -> bool
[src]
Returns true if the GapBuffer contains no elements.
pub fn get(&self, index: usize) -> Option<&T>
[src]
Returns a reference to an element at index or None if out of bounds.
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
[src]
Returns a mutable reference to an element at index or None if out of bounds.
pub fn swap(&mut self, a: usize, b: usize)
[src]
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()
.
pub fn range(&self, range: impl RangeBounds<usize>) -> Range<'_, T>
[src]
Return a immutable sub-range of this Slice.
Panics
Panics if range
is out of bounds.
Examples
use gapbuf::gap_buffer; 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]);
pub fn range_mut(&mut self, range: impl RangeBounds<usize>) -> RangeMut<'_, T>
[src]
Return a mutable sub-range of this Slice.
Panics
Panics if range
is out of bounds.
Examples
use gapbuf::gap_buffer; 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]);
pub fn as_slices(&self) -> (&[T], &[T])
[src]
Returns a pair of slices. First slice is before gap. Second slice is after gap.
Examples
use gapbuf::gap_buffer; 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]);
pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T])
[src]
Returns a pair of slices. First slice is before gap. Second slice is after gap.
Examples
use gapbuf::gap_buffer; 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]);
pub fn iter(&self) -> Iter<'_, T>
[src]
Returns an iterator over the Slice.
pub fn iter_mut(&mut self) -> IterMut<'_, T>
[src]
Returns an iterator that allows modifying each value.
Trait Implementations
impl<'a, T> Debug for RangeMut<'a, T> where
T: Debug,
[src]
T: Debug,
impl<'a, T> Default for RangeMut<'a, T>
[src]
impl<'a, T> Deref for RangeMut<'a, T>
[src]
impl<'a, T> DerefMut for RangeMut<'a, T>
[src]
impl<'a, T: Eq> Eq for RangeMut<'a, T>
[src]
impl<'a, T: Hash + 'a> Hash for RangeMut<'a, T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, T> Index<usize> for RangeMut<'a, T>
[src]
impl<'a, T> IndexMut<usize> for RangeMut<'a, T>
[src]
impl<'a, 'b, T> IntoIterator for &'a RangeMut<'b, T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T>
[src]
impl<'a, T> IntoIterator for &'a mut RangeMut<'a, T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, T>
[src]
impl<'a, T: Ord> Ord for RangeMut<'a, T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a, T, S> PartialEq<S> for RangeMut<'a, T> where
T: PartialEq,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
[src]
T: PartialEq,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
impl<'a, T, S> PartialOrd<S> for RangeMut<'a, T> where
T: PartialOrd,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
[src]
T: PartialOrd,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for RangeMut<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> Send for RangeMut<'a, T> where
T: Send,
T: Send,
impl<'a, T> Sync for RangeMut<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for RangeMut<'a, T>
impl<'a, T> !UnwindSafe for RangeMut<'a, T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,