Skip to content

Instantly share code, notes, and snippets.

@Gottox
Created December 22, 2019 16:15
Show Gist options
  • Save Gottox/f23a90cccce136dd2b68346ed1fba79f to your computer and use it in GitHub Desktop.
Save Gottox/f23a90cccce136dd2b68346ed1fba79f to your computer and use it in GitHub Desktop.
Compiling testproject v0.1.0 (/tmp/testproject)
warning: unused import: `tokio::stream::StreamExt`
--> src/main.rs:2:5
|
2 | use tokio::stream::StreamExt;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0599]: no method named `filter_map` found for type `tokio::net::tcp::incoming::Incoming<'_>` in the current scope
--> src/main.rs:7:29
|
7 | rev_listener.incoming().filter_map(|x| x.ok());
| ^^^^^^^^^^ method not found in `tokio::net::tcp::incoming::Incoming<'_>`
|
= note: the method `filter_map` exists but the following trait bounds were not satisfied:
`&mut tokio::net::tcp::incoming::Incoming<'_> : std::iter::Iterator`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.
error: could not compile `testproject`.
To learn more, run the command again with --verbose.
use tokio::net::TcpListener;
use tokio::stream::StreamExt;
use std::error::Error;
async fn listen() -> Result<(), Box<dyn Error>> {
let mut rev_listener = TcpListener::bind("127.0.0.1:8000").await?;
rev_listener.incoming().filter_map(|x| x.ok());
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