Skip to content

Commit c6db118

Browse files
authored
Merge pull request #472 from rust-lang/ch19-advanced-features.md
merge chapter 19-20 into 19
2 parents 25ed4f0 + d5a7a25 commit c6db118

8 files changed

+87
-69
lines changed

src/SUMMARY.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@
8888

8989
- [Patterns](ch18-00-patterns.md) (perhaps an appendix?)
9090

91-
- [More Lifetimes](ch19-00-more-lifetimes.md) (perhaps merge this into advanced type system features?)
91+
- [Advanced Features](ch19-00-advanced-features.md)
92+
- [Unsafe Rust](ch19-01-unsafe-rust.md)
93+
- [Advanced Lifetimes](ch19-02-advanced-lifetimes.md)
94+
- [Advanced Traits](ch19-03-advanced-traits.md)
9295

93-
- [Advanced Type System Features](ch20-00-advanced-types.md) (perhaps called "Advanced Traits"?)
96+
- [Un-named project](ch20-00-unnamed-project.md)
9497

9598
- [Appendix](appendix-00.md)
9699
- [Keywords](appendix-01-keywords.md)

src/ch19-00-advanced-features.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Advanced Features
2+
3+
We've come a long way! By now, we've learned 99% of the things you'll need to
4+
know when writing Rust. We'll wrap the book up by doing one more project, but
5+
before we get to that, let's talk about a few things that you may run into that
6+
last 1% of the time. Feel free to skip this chapter and come back to it once
7+
you run into these things in the wild; the tools we'll learn to use here are
8+
useful in very specific situations. We don't want to leave them out, but you
9+
won't find yourself reaching for them often.
10+
11+
Here's a quick summary:
12+
13+
* Unsafe Rust: for when you need to tell Rust "just trust me, promise!"
14+
* Advanced Lifetimes: Additional lifetime syntax for complex situations.
15+
* Advanced Traits: Associated Types, coherence, and disambiguation.

src/ch19-00-more-lifetimes.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/ch19-01-unsafe-rust.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Unsafe Rust
2+
3+
Things you may do in an unsafe block that you may not in safe rust
4+
5+
- deref a raw pointer
6+
- call an unsafe fn
7+
- access or modify a static variable
8+
- impl an unsafe trait
9+
10+
Go see other stuff
11+
12+
Here's the syntax tho
13+
14+
You know unsafe blocks are the cause of any crashes
15+
16+
wrap all the unsafe, make it as small as possible, present a safe public API
17+
18+
## Raw Pointers
19+
20+
## Unsafe Functions
21+
22+
### `transmute`
23+
24+
never ever. don't. stop.
25+
26+
### `extern fn`
27+
28+
You have to write unsafe code to FFI
29+
30+
## `static`
31+
32+
## Unsafe Traits

src/ch19-02-advanced-lifetimes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Advanced Lifetimes
2+
3+
### Lifetimes that depend on other lifetimes
4+
5+
'a: 'b stuff: subtyping
6+
7+
### Higher ranked trait bounds
8+
9+
for<'a>
10+
11+
Needed for closures

src/ch19-03-advanced-traits.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Advanced Traits
2+
3+
## Associated Types
4+
5+
More common than the other things, less common than the rest of the book
6+
7+
why this is a thing instead of a generic
8+
9+
## The Thing Formerly Known as UFCS
10+
11+
Only needed when implementing super generic code
12+
13+
Lots of things are syntax sugar for this
14+
15+
Two traits that impl the same method - how to disambiguate
16+
17+
## Coherence
18+
19+
Show examples of when you control traits and types or not
20+
21+
Ex: Cannot impl Debug on someone else's type
22+
23+
Solution: newtype

src/ch20-00-advanced-types.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/ch20-00-unnamed-project.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Un-named project

0 commit comments

Comments
 (0)