pub struct CustomArgs {
pub product: i32,
pub sum: i32,
}
Expand description
An example showing how to add extra arguments to a constructor and use those arguments to initialize the existing fields.
It is defined as follows:
#[make_constructor(pub new(a: i32, b: i32))]
/// ^ Returns a new instance of `CustomArgs` with `product` equal to `a * b` and `sum` equal to
/// ^ `a + b`.
pub struct CustomArgs {
#[value(a * b)]
pub product: i32,
#[value(a + b)]
pub sum: i32,
}
Note that if the #[value()]
annotations were ommitted for any field, the macro would add that
field as an additional argument to the constructor automatically.
Fields§
§product: i32
§sum: i32
Implementations§
Auto Trait Implementations§
impl Freeze for CustomArgs
impl RefUnwindSafe for CustomArgs
impl Send for CustomArgs
impl Sync for CustomArgs
impl Unpin for CustomArgs
impl UnwindSafe for CustomArgs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more