Welcome To Rust Notes

Folks learn in different ways. For me, the best way is writing and publishing notes. The process of explaining things cements them in my head.

I'm currently learning Rust. I've decided to amp things up a bit and build an entire site for to the notes. While it's not exactly a tutorial, I'm putting the site in an order designed to work from start to finish.

I hope you find it useful,

-alan

How It Works

Most pages on the site have examples. They start with the full source code followed by a step by step guide and notes. The last block of code shows the full source again. That one is editable and you can run it directly on the site. Here's "Hello, World" to get you started. Feel free to experiment.

Full Source Code

fn main() {
  println!("Hello, World");
}

Step By Step

Add the main function

fn main() {

}
The examples on this site are full programs. They all begin with a `main` function which is what Rust uses to start things off by default.

Stub a print line expression

fn main() {
  println!("Hello, World");
}
Printing to the terminal is done with the `println!()` expression. The `!` in there means `println` is a type of expression called a `macro`. We need to cover a few other topics before those will make sense. For now, just know that the `!` is required and it's easy to miss.

Add the string to print

fn main() {
  println!("Hello, World");
}
The content inside the quotes of a `println!()` expression is called a format string. This one just has the `Hello, World` text in it. It's also possible to output variables which we'll see shortly.

Run it

fn main() {
  println!("Hello, World");
}
This is the full example again. It's editable and you can run it directly on the site. Play around with it and don't worry about breaking anything. It's easy to cause giant error messages but you won't hurt anything.

TODO

  • Add styling around examples
  • Turn off search since there is no backend
  • Check highlight styles and fades in the different themes
  • Turn off Run option for partial examples
  • Make run button always visible
  • Make run button say Run
  • Turn off undo button (feels more noise then useful)
  • Prevent top bar from floating back in and covering run buttons
  • Add notes section after the examples