Fix formatting

This commit is contained in:
Marcello 2021-08-13 19:03:14 +02:00
parent dd447cfbcc
commit 613963b4df

View file

@ -51,7 +51,8 @@ io::stdin() // read line from stdin
.expect("Error Message"); // in case of errors return an error message (io::Result) -- NEEDED
```
The `::` syntax in the `::new` line indicates that `new` is an **associated function** of the `String` type. An associated function is implemented on a type rather than on a particular instance of the type. Some languages call this a `static method`.
The `::` syntax in the `::new` line indicates that `new` is an **associated function** of the `String` type.
An associated function is implemented on a type rather than on a particular instance of the type. Some languages call this a `static method`.
The `&` indicates that this argument is a reference, which gives a way to let multiple parts of the code access one piece of data without needing to copy that data into memory multiple times.
@ -74,7 +75,8 @@ const CONSTANT_NAME: type = value; // constant must have the type annotation
It's possible declare a new variable with the *same name* as a previous variable, and the new variable *shadows* the previous variable.
By using let, it's possible to perform a few transformations on a value but have the variable be immutable after those transformations have been completed.
The other difference between *mut* and *shadowing* is that because were effectively creating a new variable when we use the let keyword again, we can change the type of the value but reuse the same name.
The other difference between *mut* and *shadowing* is that because were effectively creating a new variable when we use the let keyword again,
we can change the type of the value but reuse the same name.
```rs
let x: u32 = 10;
@ -533,7 +535,8 @@ enum Option<T> {
### Match Expression + Comparing
A **match expression** is made up of *arms*. An arm consists of a *pattern* and the code that should be run if the value given to the beginning of the match expression fits that arms pattern.
A **match expression** is made up of *arms*.
An arm consists of a *pattern* and the code that should be run if the value given to the beginning of the match expression fits that arms pattern.
Rust takes the value given to match and looks through each arms pattern in turn.
**NOTE**: `match` arms must be exaustive for compilation.
@ -595,7 +598,3 @@ let v = vec![
Enum::Text("TEST")
];
```
### String
### Hash Map