Learning Rust
Programs based on the official Rust Book 2.0
Summary
- hello_world
- Use
println!
macro
- Use
- hello_cargo
- Use cargo package manager
- guessing_game
- Use external crate(
rand
) - Defining a trait
- Creating new variables with
let
- Creating new mutable variables with
mut
- Using associate(static) methods with
::
- Type annotations
- Variable shadowing
- Handling results
- Using
loop
s - Using
break
- Using
match
- Using
cmp
- Using
rand
...
- Use external crate(
- variables
- Declaring immutable variables with
let
- Declaring mutable variables with
mut
- Declaring constants with
const
- Value and type shadowing
- Differnce between the three types
- Declaring immutable variables with
- data_types
- Declaring scalar and compound data-types(tuple and arrays)
- Declaring variables with types (& sometimes size)
- Creating fixed length arrays
- Accessing elements of compound data-types
- functions
- Creating functions using
fn
- with parameters and return types(appended after
->
) - with explicit returns
- with implicit returns
- with parameters and return types(appended after
- Creating functions using
- control_flow
- Using
if
/else
/else if
- Using conditional as expressions
- Creating and
break
ingloop
s - That
break
return the value of the following expression - Using
while
- Using
for
- Using
..
to generate range - Using
iter()
method to iterate through an array - Using
rev()
method to reverse a range
- Using
- f2c
- Using function on strings
- Dabble into iterators
- Using
if
conditional - Creating functions with
fn
- fibonacci
- Used recursive function
- Alternative using iteration
- Learned that Rust still doesn't support destructuring assignment
- And also no sane way to use yield
- The iterative alt. function has a bug!
- christmas_song
- More conditionals
- Using
..
operator for iteration - That
{:?}
is for debug purposes