pub enum ProjectionElem<V, T> {
    Deref,
    Field(FieldIdx, T),
    Index(V),
    ConstantIndex {
        offset: u64,
        min_length: u64,
        from_end: bool,
    },
    Subslice {
        from: u64,
        to: u64,
        from_end: bool,
    },
    Downcast(Option<Symbol>, VariantIdx),
    OpaqueCast(T),
}

Variants§

§

Deref

§

Field(FieldIdx, T)

A field (e.g., f in _1.f) is one variant of ProjectionElem. Conceptually, rustc can identify that a field projection refers to either two different regions of memory or the same one between the base and the ‘projection element’. Read more about projections in the rustc-dev-guide

§

Index(V)

Index into a slice/array.

Note that this does not also dereference, and so it does not exactly correspond to slice indexing in Rust. In other words, in the below Rust code:

let x = &[1, 2, 3, 4];
let i = 2;
x[i];

The x[i] is turned into a Deref followed by an Index, not just an Index. The same thing is true of the ConstantIndex and Subslice projections below.

§

ConstantIndex

Fields

§offset: u64

index or -index (in Python terms), depending on from_end

§min_length: u64

The thing being indexed must be at least this long. For arrays this is always the exact length.

§from_end: bool

Counting backwards from end? This is always false when indexing an array.

These indices are generated by slice patterns. Easiest to explain by example:

[X, _, .._, _, _] => { offset: 0, min_length: 4, from_end: false },
[_, X, .._, _, _] => { offset: 1, min_length: 4, from_end: false },
[_, _, .._, X, _] => { offset: 2, min_length: 4, from_end: true },
[_, _, .._, _, X] => { offset: 1, min_length: 4, from_end: true },
§

Subslice

Fields

§from: u64
§to: u64
§from_end: bool

Whether to counts from the start or end of the array/slice. For PlaceElems this is true if and only if the base is a slice. For ProjectionKind, this can also be true for arrays.

These indices are generated by slice patterns.

If from_end is true slice[from..slice.len() - to]. Otherwise array[from..to].

§

Downcast(Option<Symbol>, VariantIdx)

“Downcast” to a variant of an enum or a generator.

The included Symbol is the name of the variant, used for printing MIR.

§

OpaqueCast(T)

Like an explicit cast from an opaque type to a concrete type, but without requiring an intermediate variable.

Auto Trait Implementations§

§

impl<V, T> RefUnwindSafe for ProjectionElem<V, T>where T: RefUnwindSafe, V: RefUnwindSafe,

§

impl<V, T> Send for ProjectionElem<V, T>where T: Send, V: Send,

§

impl<V, T> Sync for ProjectionElem<V, T>where T: Sync, V: Sync,

§

impl<V, T> Unpin for ProjectionElem<V, T>where T: Unpin, V: Unpin,

§

impl<V, T> UnwindSafe for ProjectionElem<V, T>where T: UnwindSafe, V: 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Q, K> Equivalent<K> for Qwhere 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 Qwhere 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 Twhere 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 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.
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.
source§

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

Performs the conversion.
source§

impl<N> NodeTrait for Nwhere N: Copy + Ord + Hash,