Trait thin::FnMove
[−]
[src]
pub trait FnMove<Args>: FnOnce<Args> { unsafe fn call_move(&mut self, args: Args) -> Self::Output; }
A version of FnOnce that takes self
by &mut
reference instead of by value.
This allows you to implement FnOnce on a type owning an FnMove trait object, as long as the wrapper type is Sized.
This trait will be obsolete once the unsized rvalues RFC is implemented.
Required Methods
unsafe fn call_move(&mut self, args: Args) -> Self::Output
Unsafety
Unsafe because this takes self
by reference, but treats it as moved.
The caller must somehow stop the closure's destructor from running afterwards,
whether that's by calling mem::forget
on it or something else.
Trait Implementations
impl<'a, Args, Output> DynSized for FnMove<Args, Output = Output> + 'a
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const FnMove<Args, Output = Output> + 'a
[src]
vtable: Vtable,
data: *const ()
) -> *const FnMove<Args, Output = Output> + 'a
fn disassemble(
ptr: *const FnMove<Args, Output = Output> + 'a
) -> (<FnMove<Args, Output = Output> + 'a as DynSized>::Meta, *const ())
[src]
ptr: *const FnMove<Args, Output = Output> + 'a
) -> (<FnMove<Args, Output = Output> + 'a as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
impl<'a, Args, Output> DynSized for FnMove<Args, Output = Output> + 'a + Send
[src]
type Meta = Vtable
fn assemble(
vtable: Vtable,
data: *const ()
) -> *const FnMove<Args, Output = Output> + 'a + Send
[src]
vtable: Vtable,
data: *const ()
) -> *const FnMove<Args, Output = Output> + 'a + Send
fn disassemble(
ptr: *const FnMove<Args, Output = Output> + 'a + Send
) -> (<FnMove<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
[src]
ptr: *const FnMove<Args, Output = Output> + 'a + Send
) -> (<FnMove<Args, Output = Output> + 'a + Send as DynSized>::Meta, *const ())
fn assemble_mut(meta: Self::Meta, data: *mut ()) -> *mut Self
[src]
fn disassemble_mut(ptr: *mut Self) -> (Self::Meta, *mut ())
[src]
fn meta(&self) -> Self::Meta
[src]
fn data(&self) -> *const ()
[src]
fn data_mut(&mut self) -> *mut ()
[src]
Implementors
impl<F, Args> FnMove<Args> for F where
F: FnOnce<Args>,