Advertisement
cwchen

[Rust] Using Result objects

Sep 8th, 2017
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.17 KB | None | 0 0
  1. fn main() {
  2.     let num = match "12345".parse::<u32>() {
  3.         Ok(n) => n,
  4.         Err(_) => panic!("Unable to parse integer"),
  5.     };
  6.  
  7.     assert_eq!(num, 12345);
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement