Skip to content

Instantly share code, notes, and snippets.

@Gottox
Created December 23, 2019 13:35
Show Gist options
  • Save Gottox/41923f12b33e71eb124d7f033b2987ca to your computer and use it in GitHub Desktop.
Save Gottox/41923f12b33e71eb124d7f033b2987ca to your computer and use it in GitHub Desktop.
Compiling testproject v0.1.0 (/tmp/testproject)
error[E0277]: the trait bound `std::future::GenFuture<[static generator@src/main.rs:8:31: 8:41 x:_ _]>: std::marker::Unpin` is not satisfied in `impl core::future::future::Future`
--> src/main.rs:10:39
|
10 | while let Some(stream) = incoming.next().await {
| ^^^^ within `impl core::future::future::Future`, the trait `std::marker::Unpin` is not implemented for `std::future::GenFuture<[static generator@src/main.rs:8:31: 8:41 x:_ _]>`
|
= help: the following implementations were found:
<std::future::GenFuture<T> as std::marker::Unpin>
= note: required because it appears within the type `impl core::future::future::Future`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `futures_util::stream::stream::filter_map::FilterMap<tokio::net::tcp::incoming::Incoming<'_>, impl core::future::future::Future, [closure@src/main.rs:8:21: 8:41]>`
error[E0277]: the trait bound `std::future::GenFuture<[static generator@src/main.rs:8:31: 8:41 x:_ _]>: std::marker::Unpin` is not satisfied in `impl core::future::future::Future`
--> src/main.rs:10:30
|
10 | while let Some(stream) = incoming.next().await {
| ^^^^^^^^^^^^^^^^^^^^^ within `impl core::future::future::Future`, the trait `std::marker::Unpin` is not implemented for `std::future::GenFuture<[static generator@src/main.rs:8:31: 8:41 x:_ _]>`
|
= help: the following implementations were found:
<std::future::GenFuture<T> as std::marker::Unpin>
= note: required because it appears within the type `impl core::future::future::Future`
= note: required because of the requirements on the impl of `std::marker::Unpin` for `futures_util::stream::stream::filter_map::FilterMap<tokio::net::tcp::incoming::Incoming<'_>, impl core::future::future::Future, [closure@src/main.rs:8:21: 8:41]>`
= note: required because of the requirements on the impl of `core::future::future::Future` for `futures_util::stream::stream::next::Next<'_, futures_util::stream::stream::filter_map::FilterMap<tokio::net::tcp::incoming::Incoming<'_>, impl core::future::future::Future, [closure@src/main.rs:8:21: 8:41]>>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
error: could not compile `testproject`.
To learn more, run the command again with --verbose.
use tokio::net::TcpListener;
use futures::stream::StreamExt;
use std::error::Error;
async fn listen() -> Result<(), Box<dyn Error>> {
let mut listener = TcpListener::bind("127.0.0.1:8000").await?;
let mut incoming = listener.incoming()
.filter_map(|x| async { x.ok() });
while let Some(stream) = incoming.next().await {
}
Ok(())
}
#[tokio::main]
async fn main() {
listen().await;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment