-
Notifications
You must be signed in to change notification settings - Fork 331
Remove Ok(()) with .await as end statement #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Make app.listen more ergonomic.
Before
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async { Ok("Hello, world!") });
app.listen("127.0.0.1:8080").await?;
Ok(())
}
After
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async { Ok("Hello, world!") });
app.listen("127.0.0.1:8080").await
}
|
I'm not sure if we should do this -- The lang team is exploring options to remove the need for |
|
The output is I don't think it is necessary to use Regarding the lang team solving |
|
+1 to the suggestion. app.listen("127.0.0.1:8080").await?;
Ok(())makes it unclear what app.listen returns, without looking it up in the docs. do I need to consume something there? Is it something important? app.listen("127.0.0.1:8080").awaitin contrast makes it clear with the context given that it returns an io::Result<()> so there is no data to look for coming form |
|
Yes, Edit: The other reason being the cool factor, how cool is it to be able to listen as the last return and it looks quite idiomatic and mind-blown to me. |
|
We should probably look to having a return value of Edit: I realized this morning that would be more on |
Make
app.listenmore ergonomic.Before
After