added link to Chinese translation rec#issuecomment-613319223 + minor cleanup of code in Pin chapter
This commit is contained in:
@@ -203,9 +203,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(),
|
||||
}
|
||||
}
|
||||
@@ -404,10 +403,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>) {
|
||||
@@ -509,12 +507,10 @@ you'll get a compilation error.</p>
|
||||
</span><span class="boring">
|
||||
</span><span class="boring">impl Test {
|
||||
</span><span class="boring"> fn new(txt: &str) -> Self {
|
||||
</span><span class="boring"> let a = String::from(txt);
|
||||
</span><span class="boring"> Test {
|
||||
</span><span class="boring"> a,
|
||||
</span><span class="boring"> a: let a = String::from(txt),
|
||||
</span><span class="boring"> b: std::ptr::null(),
|
||||
</span><span class="boring"> // This makes our type `!Unpin`
|
||||
</span><span class="boring"> _marker: PhantomPinned,
|
||||
</span><span class="boring"> _marker: PhantomPinned, // This makes our type `!Unpin`
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> fn init<'a>(self: Pin<&'a mut Self>) {
|
||||
@@ -566,12 +562,10 @@ after it's initialized like this:</p>
|
||||
</span><span class="boring">
|
||||
</span><span class="boring">impl Test {
|
||||
</span><span class="boring"> fn new(txt: &str) -> Self {
|
||||
</span><span class="boring"> let a = String::from(txt);
|
||||
</span><span class="boring"> Test {
|
||||
</span><span class="boring"> a,
|
||||
</span><span class="boring"> a: String::from(txt),
|
||||
</span><span class="boring"> b: std::ptr::null(),
|
||||
</span><span class="boring"> // This makes our type `!Unpin`
|
||||
</span><span class="boring"> _marker: PhantomPinned,
|
||||
</span><span class="boring"> _marker: PhantomPinned, // This makes our type `!Unpin`
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> fn init<'a>(self: Pin<&'a mut Self>) {
|
||||
@@ -606,9 +600,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,
|
||||
};
|
||||
|
||||
@@ -204,6 +204,8 @@ async ecosystem and and rarely gets enough praise in my eyes.</p>
|
||||
<p>A special thanks to <a href="https://twitter.com/jonhoo">jonhoo</a> 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.</p>
|
||||
<h2><a class="header" href="#translations" id="translations">Translations</a></h2>
|
||||
<p><a href="https://stevenbai.top/rust/futures_explained_in_200_lines_of_rust/">This book has been translated to Chinese</a> by <a href="https://github.com/nkbai">nkbai</a>.</p>
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
@@ -204,6 +204,8 @@ async ecosystem and and rarely gets enough praise in my eyes.</p>
|
||||
<p>A special thanks to <a href="https://twitter.com/jonhoo">jonhoo</a> 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.</p>
|
||||
<h2><a class="header" href="#translations" id="translations">Translations</a></h2>
|
||||
<p><a href="https://stevenbai.top/rust/futures_explained_in_200_lines_of_rust/">This book has been translated to Chinese</a> by <a href="https://github.com/nkbai">nkbai</a>.</p>
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
@@ -206,6 +206,8 @@ async ecosystem and and rarely gets enough praise in my eyes.</p>
|
||||
<p>A special thanks to <a href="https://twitter.com/jonhoo">jonhoo</a> 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.</p>
|
||||
<h2><a class="header" href="#translations" id="translations">Translations</a></h2>
|
||||
<p><a href="https://stevenbai.top/rust/futures_explained_in_200_lines_of_rust/">This book has been translated to Chinese</a> by <a href="https://github.com/nkbai">nkbai</a>.</p>
|
||||
<h1><a class="header" href="#some-background-information" id="some-background-information">Some Background Information</a></h1>
|
||||
<p>Before we go into the details about Futures in Rust, let's take a quick look
|
||||
at the alternatives for handling concurrent programming in general and some
|
||||
@@ -1681,9 +1683,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(),
|
||||
}
|
||||
}
|
||||
@@ -1882,10 +1883,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>) {
|
||||
@@ -1987,12 +1987,10 @@ you'll get a compilation error.</p>
|
||||
</span><span class="boring">
|
||||
</span><span class="boring">impl Test {
|
||||
</span><span class="boring"> fn new(txt: &str) -> Self {
|
||||
</span><span class="boring"> let a = String::from(txt);
|
||||
</span><span class="boring"> Test {
|
||||
</span><span class="boring"> a,
|
||||
</span><span class="boring"> a: let a = String::from(txt),
|
||||
</span><span class="boring"> b: std::ptr::null(),
|
||||
</span><span class="boring"> // This makes our type `!Unpin`
|
||||
</span><span class="boring"> _marker: PhantomPinned,
|
||||
</span><span class="boring"> _marker: PhantomPinned, // This makes our type `!Unpin`
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> fn init<'a>(self: Pin<&'a mut Self>) {
|
||||
@@ -2044,12 +2042,10 @@ after it's initialized like this:</p>
|
||||
</span><span class="boring">
|
||||
</span><span class="boring">impl Test {
|
||||
</span><span class="boring"> fn new(txt: &str) -> Self {
|
||||
</span><span class="boring"> let a = String::from(txt);
|
||||
</span><span class="boring"> Test {
|
||||
</span><span class="boring"> a,
|
||||
</span><span class="boring"> a: String::from(txt),
|
||||
</span><span class="boring"> b: std::ptr::null(),
|
||||
</span><span class="boring"> // This makes our type `!Unpin`
|
||||
</span><span class="boring"> _marker: PhantomPinned,
|
||||
</span><span class="boring"> _marker: PhantomPinned, // This makes our type `!Unpin`
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> }
|
||||
</span><span class="boring"> fn init<'a>(self: Pin<&'a mut Self>) {
|
||||
@@ -2084,9 +2080,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,
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
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