pub struct Range<'gb, T: 'gb> { /* private fields */ }Expand description
Immutable sub-range of GapBuffer
This struct is created by Slice::range.
Implementations§
Source§impl<'gb, T: 'gb> Range<'gb, T>
impl<'gb, T: 'gb> Range<'gb, T>
Sourcepub fn get(&self, index: usize) -> Option<&'gb T>
pub fn get(&self, index: usize) -> Option<&'gb T>
Returns a reference to an element at index or None if out of bounds.
Unlike Slice::get, return value not borrow self.
Sourcepub fn range(&self, range: impl RangeBounds<usize>) -> Range<'gb, T>
pub fn range(&self, range: impl RangeBounds<usize>) -> Range<'gb, T>
Return a immutable sub-range of this Slice.
Unlike Slice::range, return value not borrow self.
Sourcepub fn as_slices(&self) -> (&'gb [T], &'gb [T])
pub fn as_slices(&self) -> (&'gb [T], &'gb [T])
Returns a pair of slices. First slice is before gap. Second slice is after gap.
Unlike Slice::as_slices, return value not borrow self.
Methods from Deref<Target = Slice<T>>§
Sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Returns a reference to an element at index or None if out of bounds.
Sourcepub fn range(&self, range: impl RangeBounds<usize>) -> Range<'_, T>
pub fn range(&self, range: impl RangeBounds<usize>) -> Range<'_, T>
Sourcepub fn as_slices(&self) -> (&[T], &[T])
pub fn as_slices(&self) -> (&[T], &[T])
Returns a pair of slices. First slice is before gap. Second slice is after gap.
§Examples
use gap_buf::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]);Trait Implementations§
Source§impl<'gb, T> IntoIterator for &'gb Range<'_, T>
impl<'gb, T> IntoIterator for &'gb Range<'_, T>
Source§impl<T: Ord> Ord for Range<'_, T>
impl<T: Ord> Ord for Range<'_, T>
Source§impl<T, S> PartialOrd<S> for Range<'_, T>
impl<T, S> PartialOrd<S> for Range<'_, T>
impl<T: Eq> Eq for Range<'_, T>
Auto Trait Implementations§
impl<'gb, T> Freeze for Range<'gb, T>
impl<'gb, T> RefUnwindSafe for Range<'gb, T>where
T: RefUnwindSafe,
impl<'gb, T> Send for Range<'gb, T>
impl<'gb, T> Sync for Range<'gb, T>where
T: Sync,
impl<'gb, T> Unpin for Range<'gb, T>
impl<'gb, T> UnwindSafe for Range<'gb, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more