You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even though I see it's straight out of the documentation, I think this could be made clearer.
The code is a bit odd because the first result is nothing (()).
This seems clearer to me:
use std::panic;fnmain(){let result = panic::catch_unwind(|| {"No problem here!"});assert!(result.is_ok());println!("{}", result.unwrap());let result = panic::catch_unwind(|| {panic!("oh no!");});assert!(result.is_err());}
(Alternatively, could do an assertion on the unwrapped value of result, but printing it seems clearer to me.)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Even though I see it's straight out of the documentation, I think this could be made clearer.
The code is a bit odd because the first
resultis nothing (()).This seems clearer to me:
(Alternatively, could do an assertion on the unwrapped value of result, but printing it seems clearer to me.)
All reactions