Struct OffsetVec

Source
pub struct OffsetVec<V: VecLike> { /* private fields */ }
Expand description

Packer for Vec and String etc

For all methods index add a offset

Create from Offset::offset or create

§Examples

use offset_vec::Offset;

let mut vec = vec![0, 1, 2, 3, 4];
let mut vec1 = vec.offset_mut(2);

assert_eq!(vec1, [2, 3, 4]);
assert_eq!(vec1[1], 3);

vec1[1] += 2;
assert_eq!(vec, [0, 1, 2, 5, 4]);

Implementations§

Source§

impl<V: VecLike> OffsetVec<V>

Source

pub fn origin_vec(&self) -> &V

Source

pub fn origin_vec_mut(&mut self) -> &mut V

Source

pub fn into_origin_vec(self) -> V

Source

pub fn as_slice(&self) -> &V::Slice

Source

pub fn as_mut_slice(&mut self) -> &mut V::Slice

Source

pub fn iter<'a>(&'a self) -> <&'a V::Slice as IntoIterator>::IntoIter
where &'a V::Slice: IntoIterator,

Source

pub fn iter_mut<'a>(&'a mut self) -> <&'a V::Slice as IntoIterator>::IntoIter
where &'a V::Slice: IntoIterator,

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn capacity(&self) -> usize

Source

pub fn reserve(&mut self, additional: usize)

Source

pub fn reserve_exact(&mut self, additional: usize)

Source

pub fn shrink_to_fit(&mut self)

Source

pub fn shrink_to(&mut self, min_capacity: usize)

Source

pub fn origin_offset(&self) -> usize

Source

pub fn push(&mut self, value: V::Elem)

Source

pub fn pop(&mut self) -> Option<V::Elem>

Source

pub fn remove(&mut self, index: usize) -> V::Elem

Source

pub fn insert(&mut self, index: usize, elem: V::Elem)

Source

pub fn truncate(&mut self, len: usize)

Source

pub fn append(&mut self, other: &mut V::Collection)

Source

pub fn clear(&mut self)

Source

pub fn drain<R: RangeBounds<usize>>(&mut self, range: R) -> V::Drain<'_>

Source

pub fn split_off(&mut self, at: usize) -> V::Collection

Source

pub fn resize(&mut self, new_len: usize, value: V::Elem)
where V::Elem: Clone,

Source

pub fn resize_with<F>(&mut self, new_len: usize, f: F)
where F: FnMut() -> V::Elem,

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(V::ElemRef<'_>) -> bool,

Source§

impl<V: VecLikeSolid> OffsetVec<V>

Source

pub fn retain_mut<F: FnMut(&mut V::Elem) -> bool>(&mut self, f: F)

Source

pub fn swap_remove(&mut self, index: usize) -> V::Elem

Source

pub fn pop_if<F>(&mut self, predicate: F) -> Option<V::Elem>
where F: FnOnce(&mut V::Elem) -> bool,

Source§

impl<V: VecLike<Slice = str>> OffsetVec<V>

Source

pub fn as_str(&self) -> &str

Source

pub fn as_mut_str(&mut self) -> &mut str

Source

pub fn push_str<'a>(&mut self, s: &'a str)
where V::Collection: Extend<&'a str>,

Trait Implementations§

Source§

impl<V: VecLike> AsMut<<V as VecLike>::Slice> for OffsetVec<V>

Source§

fn as_mut(&mut self) -> &mut V::Slice

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<V: VecLike> AsRef<<V as VecLike>::Slice> for OffsetVec<V>

Source§

fn as_ref(&self) -> &V::Slice

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, V: VecLike<Slice = [T]>> Borrow<[T]> for OffsetVec<V>

Source§

fn borrow(&self) -> &V::Slice

Immutably borrows from an owned value. Read more
Source§

impl<V: VecLike<Slice = str>> Borrow<str> for OffsetVec<V>

Source§

fn borrow(&self) -> &V::Slice

Immutably borrows from an owned value. Read more
Source§

impl<T, V: VecLike<Slice = [T]>> BorrowMut<[T]> for OffsetVec<V>

Source§

fn borrow_mut(&mut self) -> &mut V::Slice

Mutably borrows from an owned value. Read more
Source§

impl<V: VecLike<Slice = str>> BorrowMut<str> for OffsetVec<V>

Source§

fn borrow_mut(&mut self) -> &mut V::Slice

Mutably borrows from an owned value. Read more
Source§

impl<V: Clone + VecLike> Clone for OffsetVec<V>

Source§

fn clone(&self) -> OffsetVec<V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug + VecLike> Debug for OffsetVec<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Default + VecLike> Default for OffsetVec<V>

Source§

fn default() -> OffsetVec<V>

Returns the “default value” for a type. Read more
Source§

impl<V: VecLike> Deref for OffsetVec<V>

Source§

type Target = <V as VecLike>::Slice

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<V: VecLike> DerefMut for OffsetVec<V>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T, V: VecLike> Extend<T> for OffsetVec<V>
where V::Collection: Extend<T>,

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<V: VecLike> From<V> for OffsetVec<V>

Source§

fn from(value: V) -> Self

Converts to this type from the input type.
Source§

impl<V: VecLike> Hash for OffsetVec<V>
where V::Slice: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<V, I> Index<I> for OffsetVec<V>
where V: VecLike, I: SliceIndex<V::Slice>, V::Slice: Index<I>,

Source§

type Output = <<V as VecLike>::Slice as Index<I>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<V, I> IndexMut<I> for OffsetVec<V>
where V: VecLike, I: SliceIndex<V::Slice>, V::Slice: IndexMut<I>,

Source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<V: VecLike + IntoIterator> IntoIterator for OffsetVec<V>

Source§

type Item = <V as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <V as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V: Offset + VecLike> Offset for OffsetVec<V>

Source§

type Output = <V as Offset>::Output

Source§

type OutputMut = <V as Offset>::OutputMut

Source§

fn offset(self, i: usize) -> OffsetVec<Self::Output>

Source§

fn offset_mut(&mut self, i: usize) -> OffsetVec<&mut Self::OutputMut>

Source§

impl<V: VecLike> OffsetCheckRef for OffsetVec<V>

Source§

impl<V: VecLike> Ord for OffsetVec<V>
where V::Slice: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq, V: VecLike<Elem = T, Slice = [T]>> PartialEq<&[T]> for OffsetVec<V>

Source§

fn eq(&self, other: &&[V::Elem]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialEq, V: VecLike<Elem = T, Slice = [T]>, const N: usize> PartialEq<&[T; N]> for OffsetVec<V>

Source§

fn eq(&self, other: &&[V::Elem; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: VecLike<Slice = str>> PartialEq<&str> for OffsetVec<V>

Source§

fn eq(&self, other: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialEq, V: VecLike<Elem = T, Slice = [T]>> PartialEq<[T]> for OffsetVec<V>

Source§

fn eq(&self, other: &[V::Elem]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialEq, V: VecLike<Elem = T, Slice = [T]>, const N: usize> PartialEq<[T; N]> for OffsetVec<V>

Source§

fn eq(&self, other: &[V::Elem; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: VecLike> PartialEq<V> for OffsetVec<V>
where V::Slice: PartialEq,

Source§

fn eq(&self, other: &V) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: VecLike<Slice = str>> PartialEq<str> for OffsetVec<V>

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: VecLike> PartialEq for OffsetVec<V>
where V::Slice: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: VecLike> PartialOrd for OffsetVec<V>
where V::Slice: PartialOrd,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: VecLike> Eq for OffsetVec<V>
where V::Slice: Eq,

Auto Trait Implementations§

§

impl<V> Freeze for OffsetVec<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for OffsetVec<V>
where V: RefUnwindSafe,

§

impl<V> Send for OffsetVec<V>
where V: Send,

§

impl<V> Sync for OffsetVec<V>
where V: Sync,

§

impl<V> Unpin for OffsetVec<V>
where V: Unpin,

§

impl<V> UnwindSafe for OffsetVec<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OffsetCheck for T
where T: OffsetCheckRef,

Source§

fn offset_check(self) -> Self

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.