-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
async main()
support
#3076
Comments
Is it currently not supported? It seems like #1905 added that |
The issue arises when you are trying to use it in binary targets or for Cargo examples. A main function is mandatory there and the compiler will complain that #1905 added support to have a function be This is supported: #[wasm_bindgen(start)]
pub async fn main_js() {
// insert your code here
}
fn main() { } This isn't: #[wasm_bindgen(start)]
async fn main() {
// insert your code here
} |
Oh, that makes sense. Checking if the function name is |
Motivation
I think it would be great to support something like this:
It would add a bit of quality-of-life to prevent users from having to use weird workarounds. It would also help a bit with cross-platform codebases.
Proposed Solution
The solution is probably the same as the ones used by
tokio::main
andasync_std::main
, they usually remove theasync
keyword and insert their code inside the function. I believe the only current limitation of#[wasm_bindgen(start)]
is that it doesn't remove theasync
keyword.Alternatives
#[wasm_bindgen(start_async)]
.Additional Context
Original issue: #1904
PR: #1905
I'm happy to do a PR, but wanted to ask if this feature is desired first.
Also some pointers would be great, I briefly looked into it and the architecture around proc-macro handling in
wasm-bindgen
is quite big.The text was updated successfully, but these errors were encountered: