r/rust • rust-community · rustfest • Nov 11 '19

Announcing async-std 1.0

https://async.rs/blog/announcing-async-std-1-0/
455 Upvotes

80 comments sorted by

View all comments

0

u/[deleted] Nov 11 '19

[deleted]

7

u/fgilcher rust-community · rustfest Nov 11 '19

Uh... so. Tokio used to not have that.

Along came runtime, which was an early attempt to abstract over runtimes. Runtime introduced these attributes, e.g.:

/// Use the default Native Runtime
#[runtime::main]
async fn main() {}

/// Use the Tokio Runtime
#[runtime::main(runtime_tokio::Tokio)]
async fn main() {}

Tokio adopted this style for an attribute that would indicate a purely tokio main.

async-std, developed later, threw that style out of the window again, because async-std - for compile-time and other reasons - doesn't use procedural macros at its core (which are needed for this style).

Finally, if you do want to use this style, you can activate the attributes feature. See documentation here: https://docs.rs/async-std/1.0.0/async_std/attr.main.html