minor spelling corrections
This commit is contained in:
@@ -73,7 +73,7 @@ the needed state increases with each added step.
|
||||
|
||||
### Stackless coroutines/generators
|
||||
|
||||
This is the model used in Rust today. It a few notable advantages:
|
||||
This is the model used in Rust today. It has a few notable advantages:
|
||||
|
||||
1. It's easy to convert normal Rust code to a stackless coroutine using using
|
||||
async/await as keywords (it can even be done using a macro).
|
||||
@@ -282,7 +282,7 @@ If you try to compile this you'll get an error (just try it yourself by pressing
|
||||
|
||||
What is the lifetime of `&String`. It's not the same as the lifetime of `Self`. It's not `static`.
|
||||
Turns out that it's not possible for us in Rusts syntax to describe this lifetime, which means, that
|
||||
to make this work, we'll have to let the compiler know that _we_ control this correct.
|
||||
to make this work, we'll have to let the compiler know that _we_ control this correctly ourselves.
|
||||
|
||||
That means turning to unsafe.
|
||||
|
||||
@@ -350,7 +350,7 @@ impl Generator for GeneratorA {
|
||||
let borrowed = &to_borrow;
|
||||
let res = borrowed.len();
|
||||
|
||||
// Tricks to actually get a self reference
|
||||
// Trick to actually get a self reference
|
||||
*self = GeneratorA::Yield1 {to_borrow, borrowed: std::ptr::null()};
|
||||
match self {
|
||||
GeneratorA::Yield1{to_borrow, borrowed} => *borrowed = to_borrow,
|
||||
|
||||
@@ -46,9 +46,9 @@ cases in the API which are being explored.
|
||||
Moving such a type can cause the universe to crash. As of the time of writing
|
||||
this book, creating an reading fields of a self referential struct still requires `unsafe`.
|
||||
|
||||
7. You're not really meant to be implementing `MustStay`, but you can on nightly with a feature flag, or by adding `std::marker::PhantomPinned` to your type.
|
||||
1. You can add a `MustStay` bound on a type by nightly with a feature flag, or by adding `std::marker::PhantomPinned` to your type.
|
||||
|
||||
8. When Pinning, you can either pin a value to memory either on the stack or
|
||||
2. When Pinning, you can either pin a value to memory either on the stack or
|
||||
on the heap.
|
||||
|
||||
9. Pinning a `MustStay` pointer to the stack requires `unsafe`
|
||||
|
||||
Reference in New Issue
Block a user