enum EnFoo {
Foo1,
Foo2,
Foo3,
}
impl Default for EnFoo {
fn default() -> Self {
Self::Foo1
}
}
struct StFoo {
foo1: usize,
foo2: String,
foo3: u8,
}
impl Default for StFoo {
fn default() -> Self {
Self {
foo1: 0,
foo2: String::from("0"),
foo3: 0,
}
}
}
fn fooo(a1: EnFoo*, a2: StFoo*) {
// ...
}
fn fooo_b_mut(a1: &mut EnFoo*, a2: &mut StFoo*) {
// ...
}
// ****
// EnFoo* <--- if EnFoo == empty place then
// Create EnFoo::default()
// ****
fooo(); /* <--- ==
fn fooo(a1: EnFoo*, a2: StFoo*) {
if EnFoo == empty then ↴
""let a1 = EnFoo::default();"" <-- Internal Execution
if StFoo == empty then ↴
""let a2 = StFoo::default();"" <-- Internal Execution
Now can be accessible
a1, a2
}
*/
How about this default arguments design that implemented the Default trait only for enum and structure??