Fix error E0373 documentation
This commit is contained in:
parent
a9ead34371
commit
174135fb3b
2 changed files with 24 additions and 8 deletions
|
@ -54,19 +54,35 @@ about safety.
|
||||||
This error may also be encountered while using `async` blocks:
|
This error may also be encountered while using `async` blocks:
|
||||||
|
|
||||||
```compile_fail,E0373
|
```compile_fail,E0373
|
||||||
use std::sync::Arc;
|
use std::{sync::Arc, future::Future, pin::Pin, task::{Context, Poll}};
|
||||||
use tokio::runtime::Runtime; // 0.3.1
|
|
||||||
|
|
||||||
async fn f() {
|
async fn f() {
|
||||||
let room_ref = Arc::new(Vec::new());
|
let v = Arc::new(Vec::new());
|
||||||
|
|
||||||
let gameloop_handle = Runtime::new().unwrap().spawn(async {
|
let handle = spawn(async { //~ ERROR E0373
|
||||||
game_loop(Arc::clone(&room_ref))
|
g(Arc::clone(&v))
|
||||||
});
|
});
|
||||||
gameloop_handle.await;
|
handle.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn game_loop(v: Arc<Vec<usize>>) {}
|
fn g(v: Arc<Vec<usize>>) {}
|
||||||
|
|
||||||
|
fn spawn<F>(future: F) -> JoinHandle
|
||||||
|
where
|
||||||
|
F: Future + Send + 'static,
|
||||||
|
F::Output: Send + 'static,
|
||||||
|
{
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
struct JoinHandle;
|
||||||
|
|
||||||
|
impl Future for JoinHandle {
|
||||||
|
type Output = ();
|
||||||
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Similarly to closures, `async` blocks are not executed immediately and may
|
Similarly to closures, `async` blocks are not executed immediately and may
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
use std::{sync::Arc, future::Future, pin::Pin, task::{Context,Poll}};
|
use std::{sync::Arc, future::Future, pin::Pin, task::{Context, Poll}};
|
||||||
|
|
||||||
async fn f() {
|
async fn f() {
|
||||||
let room_ref = Arc::new(Vec::new());
|
let room_ref = Arc::new(Vec::new());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue