O'Reilly logo
  • Ivan Zderadicka thinks this is interesting:

As you can see, if some fields of a structure implement Default, you can use the trait to complete the fields you don't want to specify, as you can see with the test1 variable. Simply specify the non-default fields, and then, after the last comma, add a couple of periods (..) and then Default::default(), so that the compiler uses the Default trait to fill the other fields. You can use any function that is generic over the rest of the fields with this syntax.


Cover of Rust High Performance


Actually whole structure must implement Default not just some fields