pub struct Index<const I: usize>;Expand description
The Index type, a.k.a. δ, is used to represent a usize value at
the type level.
Index is simply defined to be parameterized by a const-generic value
of type usize. It is most often used to access generic fields by their
index, instead of by their name.
Index is also shown as δ to improve the readability of compiler error
messages.
§Example
Given the following struct definition:
ⓘ
pub struct MyContext(pub u32);The following HasField implementation would be generated, with use of
Index<0> as the field tag:
ⓘ
impl HasField<Index<0>> for MyContext {
type Value = u32;
fn get_field(&self) -> &u32 {
&self.0
}
}Trait Implementations§
impl<const I: usize> Copy for δ<I>
impl<const I: usize> Eq for δ<I>
impl<const I: usize> StructuralPartialEq for δ<I>
Auto Trait Implementations§
impl<const I: usize> Freeze for δ<I>
impl<const I: usize> RefUnwindSafe for δ<I>
impl<const I: usize> Send for δ<I>
impl<const I: usize> Sync for δ<I>
impl<const I: usize> Unpin for δ<I>
impl<const I: usize> UnwindSafe for δ<I>
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