minor spelling corrections

This commit is contained in:
Carl Fredrik Samson
2020-02-01 19:16:41 +01:00
parent 513d3ade96
commit fe8762d9c9
2 changed files with 5 additions and 5 deletions

View File

@@ -73,7 +73,7 @@ the needed state increases with each added step.
### Stackless coroutines/generators ### 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 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). 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`. 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 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. That means turning to unsafe.
@@ -350,7 +350,7 @@ impl Generator for GeneratorA {
let borrowed = &to_borrow; let borrowed = &to_borrow;
let res = borrowed.len(); 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()}; *self = GeneratorA::Yield1 {to_borrow, borrowed: std::ptr::null()};
match self { match self {
GeneratorA::Yield1{to_borrow, borrowed} => *borrowed = to_borrow, GeneratorA::Yield1{to_borrow, borrowed} => *borrowed = to_borrow,

View File

@@ -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 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`. 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. on the heap.
9. Pinning a `MustStay` pointer to the stack requires `unsafe` 9. Pinning a `MustStay` pointer to the stack requires `unsafe`