12/24/22 - https://doc.rust-lang.org/book/
println!("string");
--name!()
run a macro,name()
run a function.rustc
-- compilercargo
-- is the tool chaincargo new project_name
-- new dir and scaffolding inproject_name
-- note it's a git init'd repocargo build
-- makes a binary intarget
dircargo run
-- builds and runscargo check
-- doesn't run or build, just syntax checkcargo build --release
-- makes a prod version
Typical workflow;
$ git clone example.org/someproject
$ cd someproject
$ cargo build
Note: rm -r chapter-01/hello_cargo/.git
so that I have a single repo for this.
let apples = 5; // immutable
let mut bananas = 5; // mutable
Immutable by default, mut is mutable.
.read_line(&mut guess)
-- & indicates a reference.expect("msg')
-- echosmsg
on error{var}
-- var interpolation
let x = 5;
let y = 10;
println!("x = {x} and y + 2 = {}", y + 2);
Dependencies default to carat, "0.x.y" is "^0.x.y" (in Cargo.toml
), run cargo build
to bring new deps in.