[−][src]Trait owned::Take
A trait for taking data.
Implementing Take<T>
is like implementing Borrow<T>
but for transferring ownership.
Safety
This trait is unsafe to implement because take_unsized()
must not drop()
or otherwise use
the taken value after the closure returns.
Required methods
fn take_unsized<F, R>(self, f: F) -> R where
F: FnOnce(&mut ManuallyDrop<T>) -> R,
F: FnOnce(&mut ManuallyDrop<T>) -> R,
Takes ownership of an unsized type with the aid of a closure.
The closure is called with an mutable reference to ManuallyDrop<T>
. After the closure
returns the memory occupied by the value will be deallocated, but drop()
will not be
called on the value itself.
take_sized()
and take_owned()
are implemented in terms of this.
Provided methods
fn take_sized(self) -> T where
T: Sized,
T: Sized,
Takes ownership of Sized
type.
fn take_owned(self) -> T::Owned where
T: IntoOwned,
T: IntoOwned,
Takes ownership of the owned version of an unsized type.
Implementations on Foreign Types
impl<T> Take<T> for ManuallyDrop<T>
[src]
fn take_unsized<F, R>(self, f: F) -> R where
F: FnOnce(&mut ManuallyDrop<T>) -> R,
[src]
F: FnOnce(&mut ManuallyDrop<T>) -> R,
impl<T: ?Sized + IntoOwned> Take<T> for Box<T>
[src]
fn take_unsized<F, R>(self, f: F) -> R where
F: FnOnce(&mut ManuallyDrop<T>) -> R,
[src]
F: FnOnce(&mut ManuallyDrop<T>) -> R,
impl<T> Take<[T]> for Vec<T>
[src]
fn take_unsized<F, R>(self, f: F) -> R where
F: FnOnce(&mut ManuallyDrop<[T]>) -> R,
[src]
F: FnOnce(&mut ManuallyDrop<[T]>) -> R,
Implementors
impl<T> Take<T> for T
[src]
fn take_unsized<F, R>(self, f: F) -> R where
F: FnOnce(&mut ManuallyDrop<T>) -> R,
[src]
F: FnOnce(&mut ManuallyDrop<T>) -> R,