enum StdItem {
ArrayAsSlice,
ArrayAsMutSlice,
ArrayRepeat,
ArrayIndex,
ArrayIndexMut,
SliceIndexImpl,
SliceIndexMutImpl,
SliceIndex,
SliceIndexMut,
RangeIndex,
RangeIndexMut,
}Expand description
We do the following.
If p is a projection (for instance: var, *var, var.f, etc.), we
detect:
- whether it operates on a slice or an array (we keep track of the types)
- whether the access might mutate the value or not (it is
the case if it is in a
move,&mutor at the lhs of an assignment), and do the following transformations
// If array and mutable access:
... p[i] ...
~~>
tmp0 = &mut p
tmp1 = <[_; _] as IndexMut<_>>::index_mut(move tmp0, i)
... *tmp1 ...
// If array and non-mutable access:
... p[i] ...
~~>
tmp0 := & p
tmp1 := <[_; _] as Index<_>>::index(move tmp0, i)
... *tmp1 ...
// Omitting the slice cases, which are similarFor instance, it leads to the following transformations:
// x : [u32; N]
y : u32 = copy x[i]
~~>
tmp0 : & [u32; N] := &x
tmp1 : &u32 = <[_; _] as Index<_>>::index(move tmp0, i)
y : u32 = copy (*tmp1)
// x : &[T; N]
y : &T = & (*x)[i]
~~>
tmp0 : & [T; N] := & (*x)
tmp1 : &T = <[_; _] as Index<_>>::index(move tmp0, i)
y : &T = & (*tmp1)
// x : [u32; N]
y = &mut x[i]
~~>
tmp0 : &mut [u32; N] := &mut x
tmp1 : &mut u32 := <[_; _] as IndexMut<_>>::index_mut(move tmp0, i)
y = &mut (*tmp)
// When using an index on the lhs:
// y : [T; N]
y[i] = x
~~>
tmp0 : &mut [T; N] := &mut y;
tmp1 : &mut T = <[_; _] as IndexMut<_>>::index_mut(move tmp0, i)
*tmp1 = xVariants§
ArrayAsSlice
ArrayAsMutSlice
ArrayRepeat
ArrayIndex
ArrayIndexMut
SliceIndexImpl
SliceIndexMutImpl
SliceIndex
SliceIndexMut
RangeIndex
RangeIndexMut
Trait Implementations§
impl Copy for StdItem
impl Eq for StdItem
impl StructuralPartialEq for StdItem
Auto Trait Implementations§
impl Freeze for StdItem
impl RefUnwindSafe for StdItem
impl Send for StdItem
impl Sync for StdItem
impl Unpin for StdItem
impl UnsafeUnpin for StdItem
impl UnwindSafe for StdItem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Dedup for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<T> HashConsable for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more