/Rust-Book-Notes

Sample and experimental code, as well as notes for rust lang from the Rust Book

Primary LanguageRust

Rust Book Notes and sample code

What is this?

These are my notes from reading the Rust Book (2nd edition), including some sample code, as well as all exercise code.

Anything of interest?

So far, these are the areas of note:

Runnable exercises

  1. Temperature converter mini program written in rust view the code
    • This was the first recommended exercise in chapter 3
  2. Fibonacci program that returns nth fib number written in rust view the code
    • This was the second recommended exercise in chapter 3
  3. Twelve days of Christmas lyrics written in rust view the code
    • This was the third recommended exercise in chapter 3

Notes

  1. Notes on Ownership, borrowing, and references
    • Some personal notes to help retain material I'm reading. Not proofread or organized for that matter. May contain errors, but reflects my understanding of the material at the moment of writing

Appendices

How to run the exercises

  1. Install rust
  2. Run cargo new some_name --bin. This will create a folder named some_name which has the proper directory structure to hold the script that we will be downloading next.
    $ cargo new some_name --bin
    
  3. Either download one of the sample codes above and overwrite the main.rs file found in the previously created directory located at:
    some_name/src/main.rs
    or copy paste the file contents into the aforementioned main.rs file.
  4. Change into the directory of the some_name folder created earlier
    $ cd ./some_name
  5. Run cargo run. This should compile the downloaded code and download dependencies, as well as run the program after compilation
    $ cargo run