3 ms·
A few use cases: let foobar = Default::default(); do_something_with(foobar); // where do_something_with takes a FooBar param One I often use in unit t
by PoignardAzur 4y ago
A few use cases:
let foobar = Default::default();
do_something_with(foobar); // where do_something_with takes a FooBar param
One I often use in unit tests:
fn generate_ids<const N: usize>() -> [Id; N] { ... }
let [id_button, id_label, id_thing, id_other_thing] = generate_ids();
(before const generics were stabilized, the above code instead had multiple utility functions, eg generate_2_ids, generate_3_ids, etc)