Struct unsize::Coercion [−][src]
Enables the unsizing of a sized pointer.
Implementations
impl<F, T, U: ?Sized> Coercion<T, U, F> where
F: FnOnce(*const T) -> *const U, [src]
F: FnOnce(*const T) -> *const U,
impl<'lt, T: Any + 'lt> Coercion<T, dyn Any + 'lt>[src]
pub fn to_any() -> Self[src]
Create a coercer that unsizes and keeps dynamic type information.
Usage
use unsize::{Coercion, CoerceUnsize}; use core::any::Any; fn generic<T: Any>(ptr: &T) -> &dyn Any { ptr.unsize(Coercion::to_any()) }
impl<'lt, T: Debug + 'lt> Coercion<T, dyn Debug + 'lt>[src]
pub fn to_debug() -> Self[src]
Create a coercer that unsizes a parameter to dynamically debug its fields.
Usage
use unsize::{Coercion, CoerceUnsize}; use core::fmt::Debug; fn generic<T: Debug>(ptr: &T) -> &dyn Debug { ptr.unsize(Coercion::to_debug()) }
impl<'lt, T: Display + 'lt> Coercion<T, dyn Display + 'lt>[src]
pub fn to_display() -> Self[src]
Create a coercer that unsizes a parameter to display it.
Usage
use unsize::{Coercion, CoerceUnsize}; use core::fmt::Display; fn generic<T: Display>(ptr: &T) -> &dyn Display { ptr.unsize(Coercion::to_display()) }
impl<T, const N: usize> Coercion<[T; N], [T]>[src]
pub fn to_slice() -> Self[src]
Create a coercer that unsizes an array to a slice.
Usage
use unsize::{Coercion, CoerceUnsize}; use core::fmt::Display; fn generic<T>(ptr: &[T; 2]) -> &[T] { ptr.unsize(Coercion::to_slice()) }
impl<'lt, T: Fn(A, B, C, D, E, G) -> Ret + 'lt, Ret, A, B, C, D, E, G> Coercion<T, dyn Fn(A, B, C, D, E, G) -> Ret + 'lt>[src]
pub fn to_fn() -> Self[src]
Create a coercer that unsizes to a dynamically dispatched function.
This is implemented for function arities up to the shown one (other methods / impls are hidden in the docs for readability)
impl<'lt, T: FnMut(A, B, C, D, E, G) -> Ret + 'lt, Ret, A, B, C, D, E, G> Coercion<T, dyn FnMut(A, B, C, D, E, G) -> Ret + 'lt>[src]
pub fn to_fn_mut() -> Self[src]
Create a coercer that unsizes to a dynamically dispatched mutable function.
This is implemented for function arities up to the shown one (other methods / impls are hidden in the docs for readability)
impl<'lt, T: FnOnce(A, B, C, D, E, G) -> Ret + 'lt, Ret, A, B, C, D, E, G> Coercion<T, dyn FnOnce(A, B, C, D, E, G) -> Ret + 'lt>[src]
pub fn to_fn_once() -> Self[src]
Create a coercer that unsizes to a dynamically dispatched once function.
This is implemented for function arities up to the shown one (other methods / impls are hidden in the docs for readability)
Trait Implementations
impl<T, U: ?Sized, F: FnOnce(*const T) -> *const U> Clone for Coercion<T, U, F> where
F: Clone, [src]
F: Clone,
fn clone(&self) -> Self[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<T, U: ?Sized, F: FnOnce(*const T) -> *const U> Copy for Coercion<T, U, F> where
F: Copy, [src]
F: Copy,
impl<T, U: ?Sized, F: FnOnce(*const T) -> *const U> Debug for Coercion<T, U, F> where
F: Debug, [src]
F: Debug,
impl<T, U: ?Sized, F: FnOnce(*const T) -> *const U> Eq for Coercion<T, U, F> where
F: Eq, [src]
F: Eq,
impl<T, U: ?Sized, F: FnOnce(*const T) -> *const U> Hash for Coercion<T, U, F> where
F: Hash, [src]
F: Hash,
fn hash<H: Hasher>(&self, state: &mut H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<T, U: ?Sized, F: FnOnce(*const T) -> *const U> PartialEq<Coercion<T, U, F>> for Coercion<T, U, F> where
F: PartialEq, [src]
F: PartialEq,
Auto Trait Implementations
impl<T, U: ?Sized, F> Send for Coercion<T, U, F> where
F: Send,
F: Send,
impl<T, U: ?Sized, F> Sync for Coercion<T, U, F> where
F: Sync,
F: Sync,
impl<T, U: ?Sized, F> Unpin for Coercion<T, U, F> where
F: Unpin,
F: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,