pub unsafe trait RawCast<T>: Sized {
// Provided methods
unsafe fn from_raw(raw: &T) -> &Self { ... }
unsafe fn from_raw_mut(raw: &mut T) -> &mut Self { ... }
unsafe fn raw(&self) -> &T { ... }
unsafe fn raw_mut(&mut self) -> &mut T { ... }
}
Expand description
Casting from/to a raw type that has the same layout and alignment as the target type
Provided Methods§
Sourceunsafe fn from_raw(raw: &T) -> &Self
unsafe fn from_raw(raw: &T) -> &Self
Casts an immutable reference from the raw type
§Safety
It is up to the caller to guarantee the cast is valid.
Sourceunsafe fn from_raw_mut(raw: &mut T) -> &mut Self
unsafe fn from_raw_mut(raw: &mut T) -> &mut Self
Casts a mutable reference from the raw type
§Safety
It is up to the caller to guarantee the cast is valid.
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.