[−][src]Trait butcher::methods::ButcheringMethod
Allow to unify the behavior of the different butchering methods.
T
is the input type, which can be either owned or borrowed for 'cow
. The
from_owned
and from_borrowed
take either an owned or a borrowed T
, and
produce a given output type.
Associated Types
type Output: 'cow
The output type.
Required methods
fn from_owned(i: T) -> Self::Output
Create an output with an owned input.
fn from_borrowed(i: &'cow T) -> Self::Output
Creates an output with a borrowed input.
fn unbutcher(i: Self::Output) -> T
Creates back the initial input data.
This function will clone i
if it contains borrowed data.
Implementors
impl<'cow, T> ButcheringMethod<'cow, Box<T>> for Unbox where
T: Clone + 'cow,
[src]
T: Clone + 'cow,
type Output = Cow<'cow, T>
fn from_owned(i: Box<T>) -> Self::Output
[src]
Create an Owned
variant, using the conversion requirements described
previously.
fn from_borrowed(i: &'cow Box<T>) -> Self::Output
[src]
Create a Borrowed
variant, using the Deref
trait.
fn unbutcher(i: Self::Output) -> Box<T>
[src]
impl<'cow, T> ButcheringMethod<'cow, T> for AsDeref where
T: Deref + Borrow<<T as Deref>::Target> + 'cow,
<T as Deref>::Target: ToOwned + 'cow,
T: Into<<<T as Deref>::Target as ToOwned>::Owned>,
T: From<<<T as Deref>::Target as ToOwned>::Owned>,
[src]
T: Deref + Borrow<<T as Deref>::Target> + 'cow,
<T as Deref>::Target: ToOwned + 'cow,
T: Into<<<T as Deref>::Target as ToOwned>::Owned>,
T: From<<<T as Deref>::Target as ToOwned>::Owned>,
type Output = Cow<'cow, <T as Deref>::Target>
fn from_owned(i: T) -> Self::Output
[src]
Create an Owned
variant, containing T
.
fn from_borrowed(i: &'cow T) -> Self::Output
[src]
Create a Borrowed
variant, containing a reference to T
.
fn unbutcher(i: Self::Output) -> T
[src]
impl<'cow, T> ButcheringMethod<'cow, T> for Copy where
T: Clone + 'cow,
[src]
T: Clone + 'cow,
type Output = T
fn from_owned(i: T) -> Self::Output
[src]
Move the data.
This may be reduced to a no-op.
fn from_borrowed(i: &'cow T) -> Self::Output
[src]
Clone
the input data.
fn unbutcher(i: Self::Output) -> T
[src]
impl<'cow, T> ButcheringMethod<'cow, T> for Rebutcher where
T: Butcher<'cow> + Clone + ToOwned<Owned = T> + 'cow,
[src]
T: Butcher<'cow> + Clone + ToOwned<Owned = T> + 'cow,
type Output = <T as Butcher<'cow>>::Output
fn from_owned(i: T) -> Self::Output
[src]
fn from_borrowed(i: &'cow T) -> Self::Output
[src]
fn unbutcher(i: Self::Output) -> T
[src]
impl<'cow, T> ButcheringMethod<'cow, T> for Regular where
T: Clone + 'cow,
[src]
T: Clone + 'cow,
type Output = Cow<'cow, T>
fn from_owned(i: T) -> Self::Output
[src]
Create an Owned
variant, containing T
.
fn from_borrowed(i: &'cow T) -> Self::Output
[src]
Create a Borrowed
variant, containing a reference to T
.
fn unbutcher(i: Self::Output) -> T
[src]
Recreates the original data.
This will move the data if it owned, otherwise it will clone it.