macro_rules! vtable_indirect {
($ty:ty => $($traits:ident),* $(,)?) => { ... };
(@display $ty:ty; Display $(, $($rest:ident),*)?) => { ... };
(@display $ty:ty; $other:ident $(, $($rest:ident),*)?) => { ... };
(@display $ty:ty;) => { ... };
(@debug $ty:ty; Debug $(, $($rest:ident),*)?) => { ... };
(@debug $ty:ty; $other:ident $(, $($rest:ident),*)?) => { ... };
(@debug $ty:ty;) => { ... };
(@hash $ty:ty; Hash $(, $($rest:ident),*)?) => { ... };
(@hash $ty:ty; $other:ident $(, $($rest:ident),*)?) => { ... };
(@hash $ty:ty;) => { ... };
(@partial_eq $ty:ty; PartialEq $(, $($rest:ident),*)?) => { ... };
(@partial_eq $ty:ty; $other:ident $(, $($rest:ident),*)?) => { ... };
(@partial_eq $ty:ty;) => { ... };
(@partial_cmp $ty:ty; PartialOrd $(, $($rest:ident),*)?) => { ... };
(@partial_cmp $ty:ty; $other:ident $(, $($rest:ident),*)?) => { ... };
(@partial_cmp $ty:ty;) => { ... };
(@cmp $ty:ty; Ord $(, $($rest:ident),*)?) => { ... };
(@cmp $ty:ty; $other:ident $(, $($rest:ident),*)?) => { ... };
(@cmp $ty:ty;) => { ... };
}Expand description
Creates a VTableIndirect for generic container types by specifying which traits it implements.
Note: drop_in_place, default_in_place, and clone_into are NOT set by this macro.
These per-type operations belong in TypeOps on the crate::Shape, which allows
vtables to be shared across generic instantiations.
This macro generates wrapper functions that:
- Extract
&TfromOxPtrConstviaox.get::<T>() - Call the trait method
- Wrap the result in
Some(...)
§Standard traits
Display-> generates display fn calling<T as Display>::fmtDebug-> generates debug fn calling<T as Debug>::fmtHash-> generates hash fn calling<T as Hash>::hashPartialEq-> generates partial_eq fn calling<T as PartialEq>::eqPartialOrd-> generates partial_cmp fn calling<T as PartialOrd>::partial_cmpOrd-> generates cmp fn calling<T as Ord>::cmp
§Example
ⓘ
// Simple usage with standard traits
const VTABLE: VTableIndirect = vtable_indirect!(std::path::Path =>
Debug,
Hash,
PartialEq,
PartialOrd,
Ord,
);