The Rust Programming Language
Course code notes
p1RustSample
Description:
Hello world project created within a command line
Build:
rustc hello.rs
Run:
./hello
Output:
"Hello, Rust!"
p2RustSample
Description
Hello world project created with a cargo $ cargo new p2RustSample --bin $ cd p2RustSample $ cargo run
Build:
cargo build
Run:
cargo run
Output:
"Hello, Rust!"
p3RustSample
Description
Hello world created with Intelli Idea
Build:
button 'build' in intelli idea
Run:
button 'run' in intelli idea
Output:
"Hello, Rust"
p4RustTypeAndVars
Description
Type and vars introduction:
- operators
- fundamental data types
- scope and shadowing
- stack and heap
$ cargo new p4RustTypeAndVars --bin $ cd p4RustTypeAndVars
Build:
cargo build
Run:
cargo run
Output:
p5RustFlowControl
Description
Control flow control introduction:
- if statement
- while loop
- for loop
- match statement
Build:
cargo build
Run:
cargo run
Output:
if statement temp 33 is greater than 30 today is hot day is it hot it is too hot
while loop while loop x^2 = 2 x^2 = 4 x^2 = 8 x^2 = 16 x^2 = 32 x^2 = 128 x^2 = 256 x^2 = 512 x^2 = 1024 just loop y = 2 y = 4 y = 8 y = 16 y = 32 y = 64 y = 128 y = 256 y = 512 y = 1024
for loop simple range example x = 1 x = 2 x = 4 x = 5 x = 6 x = 7 range with enumeration 0:30 1:31 2:32 3:33 4:34 5:35 6:36 7:37 8:38 9:39 10:40
match statement the country with code 44 is UK x false is s false
p5RustFlowControl
Description
Some 3-state machine example
Build:
cargo install rand cargo update cargo build
Run:
cargo run
Input:
1 2 3 4
Output:
UNLOCKED
p6RustDataStructures
Description
Notes on "Section 4: Data Structures"
Build:
cargo build
Run:
cargo run