Search notes:

Rust

Cargo

Cargo is Rust's build system and package manager.

Creating a new project

cargo new foo-app --bin
--bin: a binary project.

Building a project

A project might be built with
cargo build

Variables

By default, variables are immutable.
let     answer = 42;  // always 42
let mut maybe  =  9;  // can be changed (is mutable)

*.toml files

toml stands for Tom's obvious minimal language.
toml files are similar to *.ini files.

Compiling source code from STDIN

$ echo 'fn main() {println!("xyz")}' | rustc - -o a.out

Functions with camelCase

For the following program, the compiler warns function camelCase should have a snake case name:
fn camelCase() { println!("warning: function `camelCase` should have a snake case name") }
fn main() { camelCase() }
The following program compiles without warning:
fn snake_case() { println!("function with snake case") }
fn main() { snake_case() }

Comments

«Normal» comments:
// xyz

/*
   bla
   bla
   bla
*/
«Documenting» comments:
///  Commenting the following item:

//!  Commenting the enclosing item.

Trying to break Rust

$ echo 'fn main() {break rust}' | rustc - -o a.out
…
error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?
…

TODO

Apparently, Windows engineers started to program in Rust, too.

See also

Other programming languages etc.

Index