[][src]Struct butcher::methods::Rebutcher

pub struct Rebutcher;

The rebutcher method.

This method will butcher again the type which is marked as such.

Example

In the following code, we destructure a struct inside another struct:

use butcher::Butcher;
use std::borrow::Cow;

#[derive(Butcher, Clone)]
struct Foo {
    #[butcher(rebutcher)]
    bar: Bar,
}
#[derive(Butcher, Clone)]
struct Bar(usize);

let input = Foo { bar: Bar(42) };
let input = Cow::Borrowed(&input);

let ButcheredFoo { bar: ButcheredBar(value) } = Foo::butcher(input);

assert_eq!(value, Cow::Owned(42));

It requires the type to implement Butcher and to implement ToOwned such that <T as ToOwned>::Owned = T. The latter requirement can be implemented with the Clone trait.

Trait Implementations

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

The output type.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.