Struct rustc_index::vec::IndexVec

source ·
pub struct IndexVec<I: Idx, T> {
    pub raw: Vec<T>,
    _marker: PhantomData<fn(_: &I)>,
}

Fields§

§raw: Vec<T>§_marker: PhantomData<fn(_: &I)>

Implementations§

source§

impl<I: Idx, T> IndexVec<I, T>

source

pub fn new() -> Self

source

pub fn from_raw(raw: Vec<T>) -> Self

source

pub fn with_capacity(capacity: usize) -> Self

source

pub fn from_elem<S>(elem: T, universe: &IndexVec<I, S>) -> Selfwhere T: Clone,

source

pub fn from_elem_n(elem: T, n: usize) -> Selfwhere T: Clone,

source

pub fn from_fn_n(func: impl FnMut(I) -> T, n: usize) -> Self

Create an IndexVec with n elements, where the value of each element is the result of func(i). (The underlying vector will be allocated only once, with a capacity of at least n.)

source

pub fn push(&mut self, d: T) -> I

source

pub fn pop(&mut self) -> Option<T>

source

pub fn len(&self) -> usize

source

pub fn next_index(&self) -> I

Gives the next index that will be assigned when push is called.

source

pub fn is_empty(&self) -> bool

source

pub fn into_iter(self) -> IntoIter<T>

source

pub fn into_iter_enumerated( self ) -> impl DoubleEndedIterator<Item = (I, T)> + ExactSizeIterator

source

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

source

pub fn iter_enumerated( &self ) -> impl DoubleEndedIterator<Item = (I, &T)> + ExactSizeIterator + '_

source

pub fn indices( &self ) -> impl DoubleEndedIterator<Item = I> + ExactSizeIterator + Clone + 'static

source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

source

pub fn iter_enumerated_mut( &mut self ) -> impl DoubleEndedIterator<Item = (I, &mut T)> + ExactSizeIterator + '_

source

pub fn drain<'a, R: RangeBounds<usize>>( &'a mut self, range: R ) -> impl Iterator<Item = T> + 'a

source

pub fn drain_enumerated<'a, R: RangeBounds<usize>>( &'a mut self, range: R ) -> impl Iterator<Item = (I, T)> + 'a

source

pub fn last(&self) -> Option<I>

source

pub fn shrink_to_fit(&mut self)

source

pub fn swap(&mut self, a: I, b: I)

source

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

source

pub fn get(&self, index: I) -> Option<&T>

source

pub fn get_mut(&mut self, index: I) -> Option<&mut T>

source

pub fn pick2_mut(&mut self, a: I, b: I) -> (&mut T, &mut T)

Returns mutable references to two distinct elements, a and b.

Panics if a == b.

source

pub fn pick3_mut(&mut self, a: I, b: I, c: I) -> (&mut T, &mut T, &mut T)

Returns mutable references to three distinct elements.

Panics if the elements are not distinct.

source

pub fn convert_index_type<Ix: Idx>(self) -> IndexVec<Ix, T>

source

pub fn ensure_contains_elem(&mut self, elem: I, fill_value: impl FnMut() -> T)

Grows the index vector so that it contains an entry for elem; if that is already true, then has no effect. Otherwise, inserts new values as needed by invoking fill_value.

source

pub fn resize_to_elem(&mut self, elem: I, fill_value: impl FnMut() -> T)

source§

impl<I: Idx, T> IndexVec<I, Option<T>>

IndexVec is often used as a map, so it provides some map-like APIs.

source

pub fn insert(&mut self, index: I, value: T) -> Option<T>

source

pub fn get_or_insert_with( &mut self, index: I, value: impl FnOnce() -> T ) -> &mut T

source

pub fn remove(&mut self, index: I) -> Option<T>

source§

impl<I: Idx, T: Clone> IndexVec<I, T>

source

pub fn resize(&mut self, new_len: usize, value: T)

source§

impl<I: Idx, T: Ord> IndexVec<I, T>

Trait Implementations§

source§

impl<I: Clone + Idx, T: Clone> Clone for IndexVec<I, T>

source§

fn clone(&self) -> IndexVec<I, T>

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<I: Idx, T: Debug> Debug for IndexVec<I, T>

source§

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

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

impl<D: Decoder, I: Idx, T: Decodable<D>> Decodable<D> for IndexVec<I, T>

source§

fn decode(d: &mut D) -> Self

source§

impl<I: Idx, T> Default for IndexVec<I, T>

source§

fn default() -> Self

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

impl<S: Encoder, I: Idx, T: Encodable<S>> Encodable<S> for IndexVec<I, T>

source§

fn encode(&self, s: &mut S)

source§

impl<I: Idx, T> Extend<T> for IndexVec<I, T>

source§

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

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

fn extend_one(&mut self, item: T)

🔬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<I: Idx, T> FromIterator<T> for IndexVec<I, T>

source§

fn from_iter<J>(iter: J) -> Selfwhere J: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
source§

impl<I: Hash + Idx, T: Hash> Hash for IndexVec<I, T>

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<I: Idx, T> Index<I> for IndexVec<I, T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: I) -> &T

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

impl<I: Idx, T> IndexMut<I> for IndexVec<I, T>

source§

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

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

impl<'a, I: Idx, T> IntoIterator for &'a IndexVec<I, T>

§

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?
source§

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more
source§

impl<'a, I: Idx, T> IntoIterator for &'a mut IndexVec<I, T>

§

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?
source§

fn into_iter(self) -> IterMut<'a, T>

Creates an iterator from a value. Read more
source§

impl<I: Idx, T> IntoIterator for IndexVec<I, T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T, Global>

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

fn into_iter(self) -> IntoIter<T>

Creates an iterator from a value. Read more
source§

impl<I: PartialEq + Idx, T: PartialEq> PartialEq<IndexVec<I, T>> for IndexVec<I, T>

source§

fn eq(&self, other: &IndexVec<I, T>) -> 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<I: Eq + Idx, T: Eq> Eq for IndexVec<I, T>

source§

impl<I: Idx, T> Send for IndexVec<I, T>where T: Send,

source§

impl<I: Idx, T> StructuralEq for IndexVec<I, T>

source§

impl<I: Idx, T> StructuralPartialEq for IndexVec<I, T>

Auto Trait Implementations§

§

impl<I, T> RefUnwindSafe for IndexVec<I, T>where T: RefUnwindSafe,

§

impl<I, T> Sync for IndexVec<I, T>where T: Sync,

§

impl<I, T> Unpin for IndexVec<I, T>where T: Unpin,

§

impl<I, T> UnwindSafe for IndexVec<I, T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 24 bytes