pub unsafe trait WithUnderlier:
TransparentWrapper<Self::Underlier>
+ Sized
+ Zeroable
+ Copy
+ Send
+ Sync
+ 'static {
type Underlier: UnderlierType;
Show 17 methods
// Provided methods
fn to_underlier(self) -> Self::Underlier { ... }
fn to_underlier_ref(&self) -> &Self::Underlier { ... }
fn to_underlier_ref_mut(&mut self) -> &mut Self::Underlier { ... }
fn to_underliers_ref(val: &[Self]) -> &[Self::Underlier] { ... }
fn to_underliers_ref_mut(val: &mut [Self]) -> &mut [Self::Underlier] { ... }
fn to_underliers_arr<const N: usize>(val: [Self; N]) -> [Self::Underlier; N] { ... }
fn to_underliers_arr_ref<const N: usize>(
val: &[Self; N],
) -> &[Self::Underlier; N] { ... }
fn to_underliers_arr_ref_mut<const N: usize>(
val: &mut [Self; N],
) -> &mut [Self::Underlier; N] { ... }
fn from_underlier(val: Self::Underlier) -> Self { ... }
fn from_underlier_ref(val: &Self::Underlier) -> &Self { ... }
fn from_underlier_ref_mut(val: &mut Self::Underlier) -> &mut Self { ... }
fn from_underliers_ref(val: &[Self::Underlier]) -> &[Self] { ... }
fn from_underliers_ref_mut(val: &mut [Self::Underlier]) -> &mut [Self] { ... }
fn from_underliers_arr<const N: usize>(
val: [Self::Underlier; N],
) -> [Self; N] { ... }
fn from_underliers_arr_ref<const N: usize>(
val: &[Self::Underlier; N],
) -> &[Self; N] { ... }
fn from_underliers_arr_ref_mut<const N: usize>(
val: &mut [Self::Underlier; N],
) -> &mut [Self; N] { ... }
fn mutate_underlier(
self,
f: impl FnOnce(Self::Underlier) -> Self::Underlier,
) -> Self { ... }
}Expand description
A type that is transparently backed by an underlier.
This trait is needed to make it possible getting the underlier type from already defined type.
Bidirectional From trait implementations are not enough, because they do not allow getting
underlier type in a generic code.
§Safety
WithUnderlier can be implemented for a type only if it’s representation is a transparent
Underlier’s representation. That’s allows us casting references of type and it’s underlier in
both directions.
Required Associated Types§
Provided Methods§
Sourcefn to_underlier(self) -> Self::Underlier
fn to_underlier(self) -> Self::Underlier
Convert value to underlier.
fn to_underlier_ref(&self) -> &Self::Underlier
fn to_underlier_ref_mut(&mut self) -> &mut Self::Underlier
fn to_underliers_ref(val: &[Self]) -> &[Self::Underlier]
fn to_underliers_ref_mut(val: &mut [Self]) -> &mut [Self::Underlier]
fn to_underliers_arr<const N: usize>(val: [Self; N]) -> [Self::Underlier; N]
fn to_underliers_arr_ref<const N: usize>( val: &[Self; N], ) -> &[Self::Underlier; N]
fn to_underliers_arr_ref_mut<const N: usize>( val: &mut [Self; N], ) -> &mut [Self::Underlier; N]
fn from_underlier(val: Self::Underlier) -> Self
fn from_underlier_ref(val: &Self::Underlier) -> &Self
fn from_underlier_ref_mut(val: &mut Self::Underlier) -> &mut Self
fn from_underliers_ref(val: &[Self::Underlier]) -> &[Self]
fn from_underliers_ref_mut(val: &mut [Self::Underlier]) -> &mut [Self]
fn from_underliers_arr<const N: usize>(val: [Self::Underlier; N]) -> [Self; N]
fn from_underliers_arr_ref<const N: usize>( val: &[Self::Underlier; N], ) -> &[Self; N]
fn from_underliers_arr_ref_mut<const N: usize>( val: &mut [Self::Underlier; N], ) -> &mut [Self; N]
fn mutate_underlier( self, f: impl FnOnce(Self::Underlier) -> Self::Underlier, ) -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.