Skip to content
Code practice for the Rust book
Rust
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ch01-02-hello-world
ch01-03-hello-cargo
ch02-00-guessing-game-tutorial
ch03-01-variables-and-mutability
ch03-02-data-types
ch03-03-how-functions-work
ch03-05-control-flow
ch03-ex1-degrees
ch03-ex2-fibonacci
ch03-ex3-twelve-days
ch04-01-what-is-ownership
ch04-02-references-and-borrowing
ch04-03-slices
ch05-01-defining-structs
ch05-02-example-structs
ch05-03-method-syntax
ch06-01-defining-an-enum
ch06-02-match
ch06-03-if-let
ch07-00-restaurant
ch08-01-vectors
ch08-02-strings
ch08-03-hash-maps
ch08-ex1-mean-median-and-mode
ch08-ex2-pig-latin
ch08-ex3-company
ch09-01-unrecoverable-errors-with-panic
ch09-02-recoverable-errors-with-result
ch09-03-to-panic-or-not-to-panic
ch10-00-generics
ch10-01-syntax
ch10-02-traits
ch10-03-lifetime-syntax
.gitignore
LICENSE
README.md

README.md

Code practice for the Rust book

This is a repository of the code practice bits in The Rust Programming Language. Each directory corresponds to a chapter or subchapter of the book, matching its URL when possible. Some examples spanning across several subchapters are merged into one directory, i.e. the extensive restaurant example of chapter 7.

Everything should compile without warning and binaries should run:

  • Unused code warnings are disabled when it makes sense.
  • Code samples that are not functional are commented out.

For code samples from the "core" text, functions and structs declarations are often inlined straight in the main() function body to follow the book reading flow. This might feel a little awkward, but the idea is to prevent mixing up concepts to much. Coding exercises that sometimes come at the end of a chapter ("exN") are written using a more "traditional" fashion.

I intend to use this as future reference, but if that's of any use for you then help yourself. The coding exercises "solutions" might help, but I offer no warranty whatsoever that they are the best ones 😉. Feel free to make pull requests if you find errors, or have better solutions to suggest.

You can’t perform that action at this time.