tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
25.44k stars 2.3k forks source link

Improvement for `#[tokio::main]` #6639

Closed Jedsek closed 3 weeks ago

Jedsek commented 3 weeks ago

Importing main from other modules or crates. has been stabilized in rust 1.79.

Maybe we could improve it a little for #[tokio::main]?

This code was not allowed before:

#[tokio::main]
async fn hello_world() {
    println!("Hello, world!");
}

note: This is backwards compatible because the previous code not allowed.

how to solved: We could add prefix before any function and then use prefix_{name} as main;.

taiki-e commented 3 weeks ago

This code was not allowed before:

No, arbitrary function names are supported.

Jedsek commented 3 weeks ago

No, arbitrary function names are supported.

Oh, I know what you mean, but I mean as a entry point.

Jedsek commented 3 weeks ago

Close it because It deviates from the semantics I thought. Thanks for tips. :)