3 ms·
By single type, I meant to hint not being able to mix ? on Options and Results in the body, but good to know that's soon possible! Though you still can't, eg, u
by zZorgz 9y ago
By single type, I meant to hint not being able to mix ? on Options and Results in the body, but good to know that's soon possible! Though you still can't, eg, use `?` in main()
- steveklabnik 9y agoThat's coming as well!
- zZorgz 9y agoInteresting. Looking at the proposal it seems specific to main() and not any void returning function, by automatically picking an exit status. I suppose I worry the construct has a lack of control (log diagnostics, exit status, cleaning, etc) when bailing and can’t handle eg continue, break too.
- steveklabnik 9y agoexit status and cleaning should be just fine, logging or something else would need to not do it, yeah. continue and break would be weird outside of loops.
- zZorgz 9y agoAlso regarding an "early return protocol", I'd also be curious for continue, break, any ! type expression. For one of the Rust projects I worked on, I wrote an unwrap macro on Option that takes a secondary ! argument.
- kibwen 9y agoTracking issue for using it in main: https://github.com/rust-lang/rust/issues/43301 https://github.com/rust-lang/rust/issues/43301
- mmstick 9y agoYou can mix them if you take your Options and convert them into Results with the Option::ok_or(E) method. do_this(x).ok_or(CustomError::ThisError)?;