@@ -12,9 +12,9 @@ Pinning makes it possible to guarantee that an object won't ever be moved.
1212To understand why this is necessary, we need to remember how ` async ` /` .await ` 
1313works. Consider the following code:
1414
15- ``` rust 
16- let  fut_one  =  ... ;
17- let  fut_two  =  ... ;
15+ ``` rust,edition2018,ignore  
16+ let fut_one = /*  ... */ ; 
17+ let fut_two = /*  ... */ ; 
1818async move { 
1919    fut_one.await; 
2020    fut_two.await; 
@@ -24,7 +24,7 @@ async move {
2424Under the hood, this creates an anonymous type that implements ` Future ` ,
2525providing a ` poll `  method that looks something like this:
2626
27- ``` rust 
27+ ``` rust,ignore  
2828// The `Future` type generated by our `async { ... }` block 
2929struct AsyncFuture { 
3030    fut_one: FutOne, 
@@ -69,7 +69,7 @@ is able to successfully complete.
6969However, what happens if we have an ` async `  block that uses references?
7070For example:
7171
72- ``` rust 
72+ ``` rust,edition2018,ignore  
7373async { 
7474    let mut x = [0; 128]; 
7575    let read_into_buf_fut = read_into_buf(&mut x); 
@@ -80,7 +80,7 @@ async {
8080
8181What struct does this compile down to?
8282
83- ``` rust 
83+ ``` rust,ignore  
8484struct ReadIntoBuf<'a> { 
8585    buf: &'a mut [u8], // points to `x` below 
8686} 
@@ -118,22 +118,22 @@ used as futures, and both implement `Unpin`.
118118
119119For example:
120120
121- ``` rust 
121+ ``` rust,edition2018,ignore  
122122use pin_utils::pin_mut; // `pin_utils` is a handy crate available on crates.io 
123123
124124// A function which takes a `Future` that implements `Unpin`. 
125- fn  execute_unpin_future (x :  impl  Future <Output  =  ()> +  Unpin ) { ...  }
125+ fn execute_unpin_future(x: impl Future<Output = ()> + Unpin) { /*  ... */  } 
126126
127- let  fut  =  async  { ...  };
127+ let fut = async { /*  ... */  }; 
128128execute_unpin_future(fut); // Error: `fut` does not implement `Unpin` trait 
129129
130130// Pinning with `Box`: 
131- let  fut  =  async  { ...  };
131+ let fut = async { /*  ... */  }; 
132132let fut = Box::pin(fut); 
133133execute_unpin_future(fut); // OK 
134134
135135// Pinning with `pin_mut!`: 
136- let  fut  =  async  { ...  };
136+ let fut = async { /*  ... */  }; 
137137pin_mut!(fut); 
138138execute_unpin_future(fut); // OK 
139139``` 
0 commit comments