Struct starlark_map::vec2::Vec2

source ·
pub struct Vec2<A, B> { /* private fields */ }
Expand description

Array of pairs (A, B), where A and B are stored separately. This reduces memory consumption when A and B have different alignments.

Implementations§

source§

impl<A, B> Vec2<A, B>

source

pub const fn new() -> Vec2<A, B>

Empty vec.

source

pub fn with_capacity(cap: usize) -> Vec2<A, B>

New instance with given capacity.

source

pub fn len(&self) -> usize

Number of elements.

source

pub fn capacity(&self) -> usize

Capacity.

source

pub fn is_empty(&self) -> bool

Is empty.

source

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

Reserve capacity for additional elements.

source

pub fn push(&mut self, a: A, b: B)

Push an element.

source

pub fn get(&self, index: usize) -> Option<(&A, &B)>

Get an element reference by index.

source

pub unsafe fn get_unchecked(&self, index: usize) -> (&A, &B)

Get an element reference by index skipping bounds check.

source

pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> (&mut A, &mut B)

Get an element mutable reference by index.

source

pub fn remove(&mut self, index: usize) -> (A, B)

Remove an element by index.

This is an O(n) operation.

source

pub fn clear(&mut self)

Remove all elements.

source

pub fn pop(&mut self) -> Option<(A, B)>

Remove the last element.

source

pub fn first(&self) -> Option<(&A, &B)>

Get the first element reference.

source

pub fn last(&self) -> Option<(&A, &B)>

Get the last element reference.

source

pub fn shrink_to_fit(&mut self)

If capacity exceeds length, shrink capacity to length.

source

pub fn iter(&self) -> Iter<'_, A, B>

Iterate over the elements.

source

pub fn sort_by<F>(&mut self, compare: F)
where F: FnMut((&A, &B), (&A, &B)) -> Ordering,

Sort the elements using given comparator.

Trait Implementations§

source§

impl<A: Allocative, B: Allocative> Allocative for Vec2<A, B>

source§

fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>)

source§

impl<A: Clone, B: Clone> Clone for Vec2<A, B>

source§

fn clone(&self) -> Vec2<A, B>

Returns a copy 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<A: Debug, B: Debug> Debug for Vec2<A, B>

source§

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

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

impl<A, B> Default for Vec2<A, B>

source§

fn default() -> Vec2<A, B>

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

impl<A, B> Drop for Vec2<A, B>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<A: Hash, B: Hash> Hash for Vec2<A, B>

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<'s, A, B> IntoIterator for &'s Vec2<A, B>

§

type Item = (&'s A, &'s B)

The type of the elements being iterated over.
§

type IntoIter = Iter<'s, A, B>

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<A, B> IntoIterator for Vec2<A, B>

§

type Item = (A, B)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<A, B>

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

fn into_iter(self) -> IntoIter<A, B>

Creates an iterator from a value. Read more
source§

impl<A: PartialEq, B: PartialEq> PartialEq for Vec2<A, B>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Eq, B: Eq> Eq for Vec2<A, B>

source§

impl<A: Send, B: Send> Send for Vec2<A, B>

source§

impl<A: Sync, B: Sync> Sync for Vec2<A, B>

Auto Trait Implementations§

§

impl<A, B> RefUnwindSafe for Vec2<A, B>

§

impl<A, B> Unpin for Vec2<A, B>
where A: Unpin, B: Unpin,

§

impl<A, B> UnwindSafe for Vec2<A, B>

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.