/learn-rs

Primary LanguageRust

Learning Rust

Programs based on the official Rust Book 2.0

Summary

  1. hello_world
    • Use println! macro
  2. hello_cargo
    • Use cargo package manager
  3. 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 loops
    • Using break
    • Using match
    • Using cmp
    • Using rand...
  4. variables
    • Declaring immutable variables with let
    • Declaring mutable variables with mut
    • Declaring constants with const
    • Value and type shadowing
    • Differnce between the three types
  5. 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
  6. functions
    • Creating functions using fn
      • with parameters and return types(appended after ->)
      • with explicit returns
      • with implicit returns
  7. control_flow
    • Using if/else/else if
    • Using conditional as expressions
    • Creating and breaking loops
    • 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
  8. f2c
    • Using function on strings
    • Dabble into iterators
    • Using if conditional
    • Creating functions with fn
  9. 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!
  10. christmas_song
    • More conditionals
    • Using .. operator for iteration
    • That {:?} is for debug purposes