Publishing the syntax I learn in rust, so I can keep my thinking as clear as possible.
I will update the article whenever I learn new syntax
Rust playground: https://play.rust-lang.org/
println!("{:?}", variable_name) prints integers, strings, vectors
Strings
// split string to form a array of vectors
let numsInStr = "3 4 25 90 233";
let numsInVec: Vec<u32> = num2
.trim().split(' ')
.map(|s| s.parse().unwrap())
.collect();
println!("{:?}", num3);
Array/Vector
let mut vector1 = vec![34,35,60,40,15]; // create vector, mut == vector1 is mutable/modifiable
vector1[3]; // get element at index 3
vector1.push(47); // push element to vector
vector1.pop(); // remove last element of the vector
vector1.len(); // get length of vector
println!("{:?}", vector1); // print vector

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Discussion (0)