From 80ccf68f55dbb70d7e5ed52ee95b3c9d1b6ce264 Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Thu, 20 Mar 2025 11:07:49 +0100 Subject: vault backup: 2025-03-20 11:07:48 --- 3 Resources/Programming/Rust.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 3 Resources/Programming/Rust.md (limited to '3 Resources/Programming/Rust.md') 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//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 -- cgit v1.2.3