@ -797,7 +797,7 @@ So they are almost the same. Rust programmers almost always use ```const```.
You write them with ALL CAPITAL LETTERS, and usually outside of the ```main``` function.
You write them with ALL CAPITAL LETTERS, and usually outside of the ```main``` function.
Two examples are: ```const NUMBER_OF_MONTHS: u32 = 12;``` and ````const SEASONS: [&str; 4] = ["Spring", "Summer", "Fall", "Winter"];```
Two examples are: ```const NUMBER_OF_MONTHS: u32 = 12;``` and ```const SEASONS: [&str; 4] = ["Spring", "Summer", "Fall", "Winter"];```
# More on references
# More on references
@ -944,7 +944,7 @@ References are very useful for functions. The rule in Rust on variables is: a va
This code will not work:
This code will not work:
```ref
```rust
fn main() {
fn main() {
let country = String::from("Austria");
let country = String::from("Austria");
print_country(country); // We print "Austria"
print_country(country); // We print "Austria"
@ -964,7 +964,7 @@ It does not work because ```country``` is destroyed. Here's how:
We can fix this by adding ```&```.
We can fix this by adding ```&```.
```ref
```rust
fn main() {
fn main() {
let country = String::from("Austria");
let country = String::from("Austria");
print_country(&country); // We print "Austria"
print_country(&country); // We print "Austria"
@ -980,7 +980,7 @@ Now ```print_country()``` is a function that takes a reference to a ```String```
Here is an example of a function that uses a mutable variable.
Here is an example of a function that uses a mutable variable.
```ref
```rust
fn main() {
fn main() {
let mut country = String::from("Austria");
let mut country = String::from("Austria");
add_hungary(&mut country);
add_hungary(&mut country);
@ -1213,11 +1213,11 @@ An array is data inside square brackets: ```[]```. Arrays:
They are very fast, however.
They are very fast, however.
The type of an array is: ```[type; number]```. For example, the type of ["One", "Two"] is [&std; 2]. This means that even these two arrays have different types:
The type of an array is: ```[type; number]```. For example, the type of ["One", "Two"] is [&str; 2]. This means that even these two arrays have different types:
```rust
```rust
let array1 = ["One", "Two"];
let array1 = ["One", "Two"];
let array["One", "Two", "Five"];
let array2 = ["One", "Two", "Five"];
```
```
A good tip: to know the type of a variable, you can "ask" the compiler by giving it bad instructions. For example:
A good tip: to know the type of a variable, you can "ask" the compiler by giving it bad instructions. For example: