added link to Chinese translation rec#issuecomment-613319223 + minor cleanup of code in Pin chapter
This commit is contained in:
23
src/4_pin.md
23
src/4_pin.md
@@ -60,9 +60,8 @@ struct Test {
|
||||
|
||||
impl Test {
|
||||
fn new(txt: &str) -> Self {
|
||||
let a = String::from(txt);
|
||||
Test {
|
||||
a,
|
||||
a: String::from(txt),
|
||||
b: std::ptr::null(),
|
||||
}
|
||||
}
|
||||
@@ -291,10 +290,9 @@ impl Test {
|
||||
fn new(txt: &str) -> Self {
|
||||
let a = String::from(txt);
|
||||
Test {
|
||||
a,
|
||||
a: String::from(txt),
|
||||
b: std::ptr::null(),
|
||||
// This makes our type `!Unpin`
|
||||
_marker: PhantomPinned,
|
||||
_marker: PhantomPinned, // This makes our type `!Unpin`
|
||||
}
|
||||
}
|
||||
fn init<'a>(self: Pin<&'a mut Self>) {
|
||||
@@ -404,12 +402,10 @@ pub fn main() {
|
||||
#
|
||||
# impl Test {
|
||||
# fn new(txt: &str) -> Self {
|
||||
# let a = String::from(txt);
|
||||
# Test {
|
||||
# a,
|
||||
# a: let a = String::from(txt),
|
||||
# b: std::ptr::null(),
|
||||
# // This makes our type `!Unpin`
|
||||
# _marker: PhantomPinned,
|
||||
# _marker: PhantomPinned, // This makes our type `!Unpin`
|
||||
# }
|
||||
# }
|
||||
# fn init<'a>(self: Pin<&'a mut Self>) {
|
||||
@@ -465,12 +461,10 @@ us from swapping the pinned pointers.
|
||||
> #
|
||||
> # impl Test {
|
||||
> # fn new(txt: &str) -> Self {
|
||||
> # let a = String::from(txt);
|
||||
> # Test {
|
||||
> # a,
|
||||
> # a: String::from(txt),
|
||||
> # b: std::ptr::null(),
|
||||
> # // This makes our type `!Unpin`
|
||||
> # _marker: PhantomPinned,
|
||||
> # _marker: PhantomPinned, // This makes our type `!Unpin`
|
||||
> # }
|
||||
> # }
|
||||
> # fn init<'a>(self: Pin<&'a mut Self>) {
|
||||
@@ -508,9 +502,8 @@ struct Test {
|
||||
|
||||
impl Test {
|
||||
fn new(txt: &str) -> Pin<Box<Self>> {
|
||||
let a = String::from(txt);
|
||||
let t = Test {
|
||||
a,
|
||||
a: String::from(txt),
|
||||
b: std::ptr::null(),
|
||||
_marker: PhantomPinned,
|
||||
};
|
||||
|
||||
@@ -64,6 +64,10 @@ A special thanks to [jonhoo](https://twitter.com/jonhoo) who was kind enough to
|
||||
give me some valuable feedback on a very early draft of this book. He has not
|
||||
read the finished product, but a big thanks is definitely due.
|
||||
|
||||
## Translations
|
||||
|
||||
[This book has been translated to Chinese](https://stevenbai.top/rust/futures_explained_in_200_lines_of_rust/) by [nkbai](https://github.com/nkbai).
|
||||
|
||||
[mdbook]: https://github.com/rust-lang/mdBook
|
||||
[book_repo]: https://github.com/cfsamson/books-futures-explained
|
||||
[example_repo]: https://github.com/cfsamson/examples-futures
|
||||
|
||||
Reference in New Issue
Block a user