[−][src]Struct butcher::methods::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]
T: Butcher<'cow> + Clone + ToOwned<Owned = T> + 'cow,
Auto Trait Implementations
impl RefUnwindSafe for Rebutcher
impl Send for Rebutcher
impl Sync for Rebutcher
impl Unpin for Rebutcher
impl UnwindSafe for Rebutcher
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,