Macro constmuck::transmutable::transmute_ref [−][src]
macro_rules! transmute_ref {
($reference : expr, $transmutable_into : expr $(,) *) => { ... };
}
Expand description
Transmutes &T
into &U
, given a TransmutableInto
,
allows transmuting between ?Sized
types.
Example
use constmuck::{
transmutable::transmute_ref,
infer_tw,
};
#[derive(Debug, PartialEq)]
#[repr(transparent)]
pub struct Wrapper<T: ?Sized>(pub T);
unsafe impl<T: ?Sized> constmuck::TransparentWrapper<T> for Wrapper<T> {}
// Transmuting from `&[u8]` to `&Wrapper<[u8]>`
const BYTES: &Wrapper<[u8]> = transmute_ref!(
b"hello" as &[u8],
infer_tw!().from_inner,
);
assert_eq!(&BYTES.0, b"hello");