Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // type inference
- fn main() {
- let val1: u32 = 42;
- // ^^^ type specified explicitly
- let val2 = 42;
- // ^ type inferred
- let val3: u32 = "42".parse().unwrap();
- // ^^^ unwrap method uses this type for conversion - c++ can't do this
- let val4 = "42".parse::<u32>().unwrap();
- // ^ no type ^^^^^^^ turbofish syntax to mention type
- println!("val {} {} {} {}", val1, val2, val3, val4);
- }
Add Comment
Please, Sign In to add comment