Skip to content

Commit

Permalink
Correcting links and tuple indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Joeyh021 authored Oct 1, 2022
1 parent a520396 commit 2f150a7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/1.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ We'll talk about type annotations and inference later.

## Types

### Basic Types ([3.2](https://doc.rust-lang.org/book/ch03-05-control-flow.html))
### Basic Types ([3.2](https://doc.rust-lang.org/book/ch03-02-data-types.html))

Rust has the following numeric types:

Expand Down Expand Up @@ -118,7 +118,7 @@ let heart_eyed_cat = '😻';

`char`s in Rust are four bytes in size, as a char is meant to represent a single Unicode scalar value, meaning it can do much more than just ASCII.

### Primitive Compound Types ([3.2](https://doc.rust-lang.org/book/ch03-05-control-flow.html))
### Primitive Compound Types ([3.2](https://doc.rust-lang.org/book/ch03-02-data-types.html))

Rust has tuples, which are used extensively. Tuples can be non-homogenous and of any length.

Expand All @@ -132,8 +132,7 @@ Tuples are accessed using dot syntax, or destructured by pattern matching (more
```rust
# let tup = (1, 2);
# let trip: (char, i32, f64) = ('A', -2, 100.01);
let one = tup.0;
let minus_two = trip.2;
let one = tup.0 + tup.1 + trip.1;
let (x, y) = tup;
let (c, i, _) = trip;
```
Expand Down Expand Up @@ -341,7 +340,7 @@ fn zip(fst: i32, snd: i32) -> (i32, i32) {

Note how in the last examples the `return` keyword was not used and there is no semicolon. This is because in Rust, (almost) everything is an expression that returns a value, even blocks. The value of the last expression in a block is the return value of the block. Ending an expression with a semicolon discards the return value. This can be a tricky concept to grasp, see [Rust by Example](https://doc.rust-lang.org/rust-by-example/expression.html) for more detail.

## Control Flow ([5.5](https://doc.rust-lang.org/book/ch03-05-control-flow.html))
## Control Flow ([3.5](https://doc.rust-lang.org/book/ch03-05-control-flow.html))

### `if` Expressions

Expand Down Expand Up @@ -553,4 +552,4 @@ fn main() {
number = maybe_collatz(number);
}
}
```
```

0 comments on commit 2f150a7

Please sign in to comment.