No description
Find a file
2020-06-21 17:14:48 +02:00
collections Collections: Add company text interface exercise 2020-06-07 17:39:22 +02:00
enum_example format 2020-05-22 16:51:56 +02:00
fibonacci Add fibonacci number generator 2020-05-02 19:25:38 +02:00
guessing_game Add guessing game 2020-05-01 20:20:57 +02:00
hello_cargo Initial commit - Hello Cargo 2020-05-01 20:20:55 +02:00
panic Add panic example 2020-06-21 17:14:48 +02:00
rectangles rectangles: Add associated function 2020-05-22 14:12:11 +02:00
restaurant restaurant: Add example on modules/structure/... 2020-05-22 18:18:34 +02:00
some_example Some enum example 2020-05-22 16:45:58 +02:00
string_slicing string slicing: enhance API to accept string slices 2020-05-22 13:28:50 +02:00
struct_example Tuple structs are a thing 2020-05-22 13:47:13 +02:00
temperature_convertor Add temperature convertor 2020-05-02 19:22:02 +02:00
twelve_days_of_christmas Add twelve days of christmas 2020-05-02 19:32:05 +02:00
.gitignore Initial commit - Hello Cargo 2020-05-01 20:20:55 +02:00
README.md README: Add how to create app/lib 2020-05-22 17:27:36 +02:00

Rust "The Book" exercices

A collection of the examples/exercices/... found in the rust tutorial "The Book", collected for my own reference.

Interesting commands

Creating

We can create a new package/application with:

$> cargo new <name_of_package>

An application has main.rs as its crate root.

We can also create a new library:

$> cargo new --lib <name_of_package>

A library has lib.rs as its crate root.

These are not mutually exclusive, we can have a library and application in the same package!

Run

Running an application.

$> cargo run

Compile

  1. Debug
$> cargo build
  1. Release
$> cargo build --release
  1. Check

This is usefull in f.e. CI's to quickly check if our project can compile:

$> cargo check

Documentation

Make and open the documentation in your favorite web browser:

$> cargo doc --open

Format

To format the code:

$> cargo fmt

Interesting things to know

  • A char is 4 bytes in Rust!

  • Breaking with a value is only possible inside a 'loop' not a 'while/for' loop!