Attribute Macro try_clone
#[try_clone]Expand description
This macro attribute implements the TryClone trait for the given struct
or enum.
It accepts a single argument, which is the type name of error type to
use with the TryClone trait.
§Example
This definition:
ⓘ
pub struct MyError;
#[try_clone(MyError)]
struct MyStruct {
a: u32,
b: bool,
}will generate the following code, in addition to the struct definition:
ⓘ
impl TryClone for MyStruct {
type Error = MyError;
fn try_clone(&self) -> Result<Self, Self::Error> {
Ok(MyStruct {
a: TryClone::try_clone(&self.a)?,
b: TryClone::try_clone(&self.b)?,
})
}
}