Guest User

Untitled

a guest
Dec 11th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // type inference
  2.  
  3. fn main() {
  4. let val1: u32 = 42;
  5. // ^^^ type specified explicitly
  6.  
  7. let val2 = 42;
  8. // ^ type inferred
  9.  
  10. let val3: u32 = "42".parse().unwrap();
  11. // ^^^ unwrap method uses this type for conversion - c++ can't do this
  12.  
  13. let val4 = "42".parse::<u32>().unwrap();
  14. // ^ no type ^^^^^^^ turbofish syntax to mention type
  15.  
  16. println!("val {} {} {} {}", val1, val2, val3, val4);
  17. }
Add Comment
Please, Sign In to add comment