You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-16 14:17:34 +02:00
18
STYLE.md
18
STYLE.md
@ -65,6 +65,24 @@ collapsed or removed entirely from the slide.
|
||||
course, instructors will only have time to glance at the notes so it is not
|
||||
useful to include full paragraphs which the instructor should read out loud.
|
||||
|
||||
### More to Explore
|
||||
|
||||
Move extended explanations in the notes to a "More to Explore" section:
|
||||
|
||||
```markdown
|
||||
<details>
|
||||
|
||||
...
|
||||
|
||||
## More to Explore
|
||||
|
||||
...
|
||||
|
||||
</details>
|
||||
```
|
||||
|
||||
The material there is outside the scope of the regular class.
|
||||
|
||||
## Translations
|
||||
|
||||
This section is about what you write in the translation. We describe
|
||||
|
@ -58,6 +58,10 @@ Key Points:
|
||||
* `dbg_size!(&i32)`: size 8 bytes, align: 8 bytes (on a 64-bit machine),
|
||||
* `dbg_size!(Option<&i32>)`: size 8 bytes, align: 8 bytes (null pointer optimization, see below).
|
||||
|
||||
## More to Explore
|
||||
|
||||
Rust has several optimizations it can employ to make enums take up less space.
|
||||
|
||||
* Niche optimization: Rust will merge unused bit patterns for the enum
|
||||
discriminant.
|
||||
|
||||
|
@ -29,7 +29,10 @@ fn main() {
|
||||
|
||||
* If students ask about it, you can mention that the underlying memory is heap allocated using the [System Allocator] and custom allocators can be implemented using the [Allocator API]
|
||||
|
||||
* We can inspect the memory layout with `unsafe` code. However, you should point out that this is rightfully unsafe!
|
||||
## More to Explore
|
||||
|
||||
We can inspect the memory layout with `unsafe` Rust. However, you should point
|
||||
out that this is rightfully unsafe!
|
||||
|
||||
```rust,editable
|
||||
fn main() {
|
||||
|
Reference in New Issue
Block a user