3 ms·
One thing I wish was better was block-scoped ?. I know there's https://doc.rust-lang.org/beta/unstable-book/language-features/try-blocks.html https://doc.rust-
by vore 4y ago
One thing I wish was better was block-scoped ?.
I know there's https://doc.rust-lang.org/beta/unstable-book/language-features/try-blocks.html https://doc.rust-lang.org/beta/unstable-book/language-featur... so you can do e.g.
let foo: Result<T, Error> = try {
x()?;
y()?;
Ok(z)
};
but it hasn't been stabilized yet. The other workaround is to make an anonymous function and invoke it immediately, but sometimes you run into janky lifetime issues with that.