Advertisement
Guest User

Untitled

a guest
May 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. fn foo(s: &str) -> Result<i32, &str> {
  2.  
  3. // it's just small temporary value
  4. let tmp = match s {
  5. "a" => 0,
  6. "b" => 42,
  7. _ => panic!("unexpected string"),
  8. // _ => return Err("unexpected string"),
  9. };
  10.  
  11. // some more computations that uses `tmp` variable to produce actual result
  12. Ok(tmp)
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement