My first impression of async-std was not positive. I've added it to the project, copy'n'pasted the first example, and I've got:
a compilation error
2 | #[async_std::main]
| ^^^^ could not find `main` in `async_std`
and then noticed the explanation that the code used in the readme would be slow to compile. That makes it feel like it's not the best thing to use, and yet it's in the README.
It would be nicer if the first example in the README compiled with default crate features, without need to enable anything first. It's also worse by the fact that the prose just links to documentation that explains features. If the TOML markup enabling the required feature was inline in the README I'd have noticed it. But I didn't read the prose on purpose, since I wanted to jump straight to the code, and ended up disappointed.
It's also annoying because surf crate has almost identical example, but it uses #[runtime::main] attribute instead. cargo add runtime adds a wrong version of runtime (it picks only stable ones).
So the first two async examples I've tried both failed to compile because of a mysteriously missing magical attribute around main.
@kornelski Thanks for open this issue!
This allowed me to notice documentation issues.
I added #[async_std::main] to my main and it's also complaining with could not find main in async_std. What's missing?
I added
#[async_std::main]to my main and it's also complaining withcould not find main in async_std. What's missing?
async-std = {version = "1", features = ["attributes"]}
Reference: https://docs.rs/async-std/1.5.0/async_std/#features
Examples in the documentation should be correct.
Most helpful comment
async-std = {version = "1", features = ["attributes"]}Reference: https://docs.rs/async-std/1.5.0/async_std/#features