[][src]Trait butcher::methods::ButcheringMethod

pub trait ButcheringMethod<'cow, T> where
    T: 'cow, 
{ type Output: 'cow; fn from_owned(i: T) -> Self::Output;
fn from_borrowed(i: &'cow T) -> Self::Output;
fn unbutcher(i: Self::Output) -> T; }

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.

Loading content...

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.

Loading content...

Implementors

impl<'cow, T> ButcheringMethod<'cow, Box<T>> for Unbox where
    T: Clone + 'cow, 
[src]

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.

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]

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.

impl<'cow, T> ButcheringMethod<'cow, T> for Copy where
    T: Clone + 'cow, 
[src]

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.

impl<'cow, T> ButcheringMethod<'cow, T> for Rebutcher where
    T: Butcher<'cow> + Clone + ToOwned<Owned = T> + 'cow, 
[src]

type Output = <T as Butcher<'cow>>::Output

impl<'cow, T> ButcheringMethod<'cow, T> for Regular where
    T: Clone + 'cow, 
[src]

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.

Loading content...