[−][src]Struct scones_examples::MultipleConstructors
An example showing how to efficiently create multiple constructors.
It is defined as follows:
#[make_constructor] /// ^ This is documentation for the first constructor. Notice how a, b, and c have been /// ^ automatically generated for us. #[make_constructor(pub new_identical(shared: i32))] /// ^ This is documentation for the second constructor. Notice how the only argument is /// ^ `shared`, since we have specified the code that sets up all the other fields in this case. pub struct MultipleConstructors { // Note that we do not provide a default `value` or `[value] for new` for any of these // fields, so the macro will automatically add parameters for them in the `new` constructor. #[value(shared for new_identical)] pub a: i32, #[value(shared for new_identical)] pub b: i32, #[value(shared for new_identical)] pub c: i32, /// This field will always be `true` when created with `new_identical` and `false` when /// created with `new`. #[value(true)] #[value(false for new)] pub identical: bool, }
Fields
a: i32
b: i32
c: i32
identical: bool
This field will always be true
when created with new_identical
and false
when
created with new
.
Implementations
impl MultipleConstructors
[src]
pub fn new(a: i32, b: i32, c: i32) -> Self
[src]
This is documentation for the first constructor. Notice how a, b, and c have been automatically generated for us.
pub fn new_identical(shared: i32) -> Self
[src]
This is documentation for the second constructor. Notice how the only argument is
shared
, since we have specified the code that sets up all the other fields in this case.
Auto Trait Implementations
impl RefUnwindSafe for MultipleConstructors
impl Send for MultipleConstructors
impl Sync for MultipleConstructors
impl Unpin for MultipleConstructors
impl UnwindSafe for MultipleConstructors
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,
pub 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.
pub 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>,