async-std icon indicating copy to clipboard operation
async-std copied to clipboard

Readme example does not simply compile

Open kornelski opened this issue 6 years ago • 5 comments

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:

  1. a compilation error

    2 | #[async_std::main]
      |              ^^^^ could not find `main` in `async_std`
    
  2. 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.

kornelski avatar Dec 07 '19 20:12 kornelski

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 avatar Dec 07 '19 20:12 kornelski

@kornelski Thanks for open this issue! This allowed me to notice documentation issues.

k-nasa avatar Dec 08 '19 13:12 k-nasa

I added #[async_std::main] to my main and it's also complaining with could not find main in async_std. What's missing?

ivnsch avatar Feb 22 '20 13:02 ivnsch

I added #[async_std::main] to my main and it's also complaining with could 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

zeljic avatar Feb 26 '20 08:02 zeljic

Examples in the documentation should be correct.

SergeiMinaev avatar Sep 04 '20 19:09 SergeiMinaev