[][src]Struct scones_examples::MultipleConstructors

pub struct MultipleConstructors {
    pub a: i32,
    pub b: i32,
    pub c: i32,
    pub identical: bool,
}

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: i32b: i32c: i32identical: 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

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.