summaryrefslogtreecommitdiff
path: root/3 Resources/Programming/Rust.md
diff options
context:
space:
mode:
Diffstat (limited to '3 Resources/Programming/Rust.md')
-rw-r--r--3 Resources/Programming/Rust.md27
1 files changed, 27 insertions, 0 deletions
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