Rust Quick Reference

main()

fn main(){
	println!("hello world");
}

/sample/r1.rs

Function are fn

println has a ! after it, as it's a macro and not a function.
And a semicolon ; after each statement.
No need to return 0 at end of main()

x=1

let x=1;
x=2; //<-- can't

let x mut=1; //<-- put a mut after variable name to reassign it later.
x=2;
//

/sample/r2.rs

Variables are declared with let

Published
2-Dec-2022
Updated
2-Dec-2022