Struct gapbuf::Range [−][src]
pub struct Range<'a, T: 'a> { /* fields omitted */ }
Immutable sub-range of GapBuffer
Methods
impl<'a, T: 'a> Range<'a, T>
[src]
impl<'a, T: 'a> Range<'a, T>
pub fn empty() -> Self
[src]
pub fn empty() -> Self
Construct a new, empty Range
.
pub fn get(&self, index: usize) -> Option<&'a T>
[src]
pub fn get(&self, index: usize) -> Option<&'a T>
pub fn range(
&self,
range: impl RangeBounds<usize>
) -> Range<'a, T>
[src]
pub fn range(
&self,
range: impl RangeBounds<usize>
) -> Range<'a, T>
pub fn as_slices(&self) -> (&'a [T], &'a [T])
[src]
pub fn as_slices(&self) -> (&'a [T], &'a [T])
Methods from Deref<Target = Slice<T>>
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of elements in the GapBuffer.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true if the GapBuffer contains no elements.
pub fn get(&self, index: usize) -> Option<&T>
[src]
pub fn get(&self, index: usize) -> Option<&T>
Returns a reference to an element at index or None if out of bounds.
pub fn range(
&self,
range: impl RangeBounds<usize>
) -> Range<T>
[src]
pub fn range(
&self,
range: impl RangeBounds<usize>
) -> Range<T>
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]);
pub fn as_slices(&self) -> (&[T], &[T])
[src]
pub fn as_slices(&self) -> (&[T], &[T])
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]);
pub fn iter(&self) -> Iter<T>
[src]
pub fn iter(&self) -> Iter<T>
Returns an iterator over the Slice.
Trait Implementations
impl<'a, T: Hash + 'a> Hash for Range<'a, T>
[src]
impl<'a, T: Hash + 'a> Hash for Range<'a, T>
fn hash<__HT: Hasher>(&self, state: &mut __HT)
[src]
fn hash<__HT: Hasher>(&self, state: &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[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a, T> Deref for Range<'a, T>
[src]
impl<'a, T> Deref for Range<'a, T>
type Target = Slice<T>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
fn deref(&self) -> &Self::Target
Dereferences the value.
impl<'a, T> Clone for Range<'a, T>
[src]
impl<'a, T> Clone for Range<'a, T>
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a, T> Default for Range<'a, T>
[src]
impl<'a, T> Default for Range<'a, T>
impl<'a, T> Index<usize> for Range<'a, T>
[src]
impl<'a, T> Index<usize> for Range<'a, T>
type Output = T
The returned type after indexing.
fn index(&self, index: usize) -> &T
[src]
fn index(&self, index: usize) -> &T
Performs the indexing (container[index]
) operation.
impl<'a, T> Debug for Range<'a, T> where
T: Debug,
[src]
impl<'a, T> Debug for Range<'a, T> where
T: Debug,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<'a, T, S> PartialEq<S> for Range<'a, T> where
T: PartialEq,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
[src]
impl<'a, T, S> PartialEq<S> for Range<'a, T> where
T: PartialEq,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
fn eq(&self, other: &S) -> bool
[src]
fn eq(&self, other: &S) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'a, T: Eq> Eq for Range<'a, T>
[src]
impl<'a, T: Eq> Eq for Range<'a, T>
impl<'a, T, S> PartialOrd<S> for Range<'a, T> where
T: PartialOrd,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
[src]
impl<'a, T, S> PartialOrd<S> for Range<'a, T> where
T: PartialOrd,
S: ?Sized,
&'b S: IntoIterator<Item = &'b T>,
fn partial_cmp(&self, other: &S) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &S) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
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 Range<'a, T>
[src]
impl<'a, T: Ord> Ord for Range<'a, T>
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<'a, 'b, T> IntoIterator for &'a Range<'b, T>
[src]
impl<'a, 'b, T> IntoIterator for &'a Range<'b, T>