3 ms·
I do this too, with a different spin on it: let foo = match foo() { Ok(foo) => foo, Err(err) => return Err(err), }; I was typing it out so oft
by ntoskrnl 4y ago
I do this too, with a different spin on it:
let foo = match foo() {
Ok(foo) => foo,
Err(err) => return Err(err),
};
I was typing it out so often I made editor aliases `lmo` and `lmr` for Option and Result
- veber-alex 4y agolet me introduce you to the famous '?' operator. The code above can be written as: let foo = foo()?;
- ntoskrnl 4y agoLOL you're right! I just pasted the template here, but my defaults are mostly equivalent to plain old `?`. I don't use the match if `?` would work.