@Ambraven@social.mochi.academy
Post #2564791
2026-04-29 20:46 UTC
@benjamingeer@piaille.fr
... Oh I know, I can do this:
fn toto(foo: Option ) {
if foo.is_none() {
toto(Some(A::new());
return;
}
let foo = foo.unwrap();
...
}
It might become a bit messy if there are more than one optional parameter though...
Replies (1)
-
@benjamingeer@piaille.fr 2026-04-29 20:58
@Ambraven@social.mochi.academy With more than one optional parameter, I think it would be clearer like this. (I think it's best not to use unwrap() except in tests.) But it might be better to try to redesign things so you don't need the options.