diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-03-20 11:07:49 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-03-20 11:07:49 +0100 |
commit | 80ccf68f55dbb70d7e5ed52ee95b3c9d1b6ce264 (patch) | |
tree | 93e28e85ab70052aa6f577998ec7dc1f413b40c0 /3 Resources/Programming | |
parent | 9642cd7ae24f0ba79ce5647c709b35ae8f06a285 (diff) |
vault backup: 2025-03-20 11:07:48
Diffstat (limited to '3 Resources/Programming')
-rw-r--r-- | 3 Resources/Programming/Integer types Rust.png | bin | 0 -> 18441 bytes | |||
-rw-r--r-- | 3 Resources/Programming/Rust.md | 27 |
2 files changed, 27 insertions, 0 deletions
diff --git a/3 Resources/Programming/Integer types Rust.png b/3 Resources/Programming/Integer types Rust.png Binary files differnew file mode 100644 index 0000000..358eb85 --- /dev/null +++ b/3 Resources/Programming/Integer types Rust.png diff --git a/3 Resources/Programming/Rust.md b/3 Resources/Programming/Rust.md new file mode 100644 index 0000000..8724ca3 --- /dev/null +++ b/3 Resources/Programming/Rust.md @@ -0,0 +1,27 @@ +https://rust-book.cs.brown.edu + +> Finished chapter 2. Onto chapter 3! + +If the name ends with ! it's a macro. + +By default, Rust has a set of items defined in the standard library that it brings into the scope of every program. This set is called the _prelude_, and you can see everything in it [in the standard library documentation](https://doc.rust-lang.org/std/prelude/index.html). + +"he `stdin` function returns an instance of [`std::io::Stdin`](https://doc.rust-lang.org/std/io/struct.Stdin.html), which is a type that represents a handle to the standard input for your terminal." +How does this work? How does it know which terminal is ours? I guess it might be connected by linux when running the process as `/proc/<pid>/stdin`. + +`&` is a reference. References are also immutable by default, thus `&mut guess` will allow us to update the reference to the variable guess. + +Enum members are called variants. + +`cargo doc --open` command will build documentation provided by all your dependencies locally and open it in your browser. + +`match` expression -> arms -> pattern + code path. Match expressions stop evaluating if a match is made; therefore we should strive to order them based on their likeliness to be hit. + +`shadowed` = when a variable name is used multiple times; e.g +``` +let x = 1 +let x = 2 <- shadowed +``` +Shadowing is different from making a variable `mutable` because it is fully reassigned (thus its type can also be changed), but the value is then still immutable (giving compiler errors when we try to reassign). + +![[Integer types Rust.png]]
\ No newline at end of file |