Closed
Description
Here's the definition
/// This trait is meant to map equivalences between raw structs and their
/// corresponding rust values.
pub trait Repr<T> {
/// This function "unwraps" a rust value (without consuming it) into its raw
/// struct representation. This can be used to read/write different values
/// for the struct. This is a safe method because by default it does not
/// enable write-access to the fields of the return value in safe code.
#[inline]
fn repr(&self) -> T { unsafe { mem::transmute_copy(&self) } }
}
Implementing is done like so:
impl<T> Repr<Slice<T>> for [T] {}
A safe implementation invokes a transmute between arbitrary types. Perhaps Repr
is more appropriately an unsafe trait?