You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-26 18:51:00 +02:00
Merge pull request #133 from rastringer/patch-1
Adds speaker notes to Compound Types section
This commit is contained in:
@ -24,3 +24,27 @@ fn main() {
|
|||||||
println!("2nd index: {}", t.1);
|
println!("2nd index: {}", t.1);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
Key points:
|
||||||
|
|
||||||
|
Arrays:
|
||||||
|
|
||||||
|
*Arrays have elements of the same type, `T`, and length, `N`, which is a compile-time constant.
|
||||||
|
|
||||||
|
*We can use literals to assign values to arrays.
|
||||||
|
|
||||||
|
*In the main function, the print statement asks for the debug implementation with the `?` format parameter: `{a}` gives the default output, `{a:?}` gives the debug output.
|
||||||
|
|
||||||
|
*Adding `#`, eg `{a:#?}`, invokes a "pretty printing" format, which can be easier to read.
|
||||||
|
|
||||||
|
Tuples:
|
||||||
|
|
||||||
|
*Like arrays, tuples have a fixed length.
|
||||||
|
|
||||||
|
*Tuples group together values of different types into a compound type.
|
||||||
|
|
||||||
|
*Fields that can be accessed by the period and the index of the value, e.g. t.0, t.1.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
Reference in New Issue
Block a user