[−][src]Trait coercion::Coerce
Unsafe, unchecked, coercion between types of the same size and alignment.
Provided methods
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
Self: Sized,
T: Sized,
Performs the coercion on an owned value.
Examples
use coercion::Coerce; // Safe because 1 is non-zero. let nonzero: NonZeroU64 = unsafe { 1u64.coerce() }; assert_eq!(nonzero.get(), 1);
fn coerce_ptr(this: *const Self) -> *const T
Perform the conversion on a const
pointer.
fn coerce_mut_ptr(this: *mut Self) -> *mut T
Perform the conversion on a mut
pointer.
Implementations on Foreign Types
impl<T, U> Coerce<[U]> for [T] where
T: Coerce<U>,
[src]
T: Coerce<U>,
fn coerce_ptr(this: *const Self) -> *const [U]
[src]
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl<T: ?Sized, U: ?Sized> Coerce<Box<U>> for Box<T> where
T: Coerce<U>,
[src]
T: Coerce<U>,
unsafe fn coerce(self) -> Box<U>
[src]
fn coerce_ptr(this: *const Self) -> *const Box<U>
[src]
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl Coerce<str> for [u8]
[src]
fn coerce_ptr(this: *const Self) -> *const str
[src]
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl Coerce<[u8]> for str
[src]
fn coerce_ptr(this: *const Self) -> *const [u8]
[src]
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl<'a, T: ?Sized, U: ?Sized> Coerce<&'a T> for &'a U where
T: Coerce<U>,
[src]
T: Coerce<U>,
fn coerce_ptr(this: *const Self) -> *const &'a T
[src]
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl<'a, T: ?Sized, U: ?Sized> Coerce<&'a mut T> for &'a mut U where
T: Coerce<U>,
[src]
T: Coerce<U>,
fn coerce_ptr(this: *const Self) -> *const &'a mut T
[src]
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl<'a, T: ?Sized, U: ?Sized> Coerce<*const T> for *const U where
T: Coerce<U>,
[src]
T: Coerce<U>,
fn coerce_ptr(this: *const Self) -> *const *const T
[src]
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl<'a, T: ?Sized, U: ?Sized> Coerce<*mut T> for *mut U where
T: Coerce<U>,
[src]
T: Coerce<U>,
fn coerce_ptr(this: *const Self) -> *const *mut T
[src]
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,
fn coerce_mut_ptr(this: *mut Self) -> *mut T
[src]
impl<T: ?Sized, U: ?Sized> Coerce<ManuallyDrop<U>> for ManuallyDrop<T> where
T: Coerce<U>,
[src]
T: Coerce<U>,
unsafe fn coerce(self) -> T where
Self: Sized,
T: Sized,
[src]
Self: Sized,
T: Sized,