Fix error E0373 documentation
This commit is contained in:
parent
a9ead34371
commit
174135fb3b
@ -54,19 +54,35 @@ about safety.
|
||||
This error may also be encountered while using `async` blocks:
|
||||
|
||||
```compile_fail,E0373
|
||||
use std::sync::Arc;
|
||||
use tokio::runtime::Runtime; // 0.3.1
|
||||
use std::{sync::Arc, future::Future, pin::Pin, task::{Context, Poll}};
|
||||
|
||||
async fn f() {
|
||||
let room_ref = Arc::new(Vec::new());
|
||||
let v = Arc::new(Vec::new());
|
||||
|
||||
let gameloop_handle = Runtime::new().unwrap().spawn(async {
|
||||
game_loop(Arc::clone(&room_ref))
|
||||
let handle = spawn(async { //~ ERROR E0373
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 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() {
|
||||
let room_ref = Arc::new(Vec::new());
|
||||
|
Loading…
Reference in New Issue
Block a user