Created
December 22, 2019 16:15
-
-
Save Gottox/f23a90cccce136dd2b68346ed1fba79f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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