-
-
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
Introduce #[wasm_bindgen(main)]
#3299
Conversation
7d48138
to
adcf286
Compare
#[wasm_bindgen(main)]
#[wasm_bindgen(main)]
4640269
to
56535fc
Compare
56535fc
to
ddb9e5d
Compare
Rebased after #3338. |
1c742d7
to
684a570
Compare
684a570
to
61f228c
Compare
Rebased after #3360. |
|
||
Unlike `#[wasm_bindgen(start)]` this will not export a function to be executed | ||
on startup, it should only be used in Cargo binaries or examples for the `main` | ||
function. `#[wasm_bindgen(start)]` will prevent the `main` function to start and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what this line is trying to say? I believe that combining them will actually cause the CLI to throw an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm trying to say is that using #[wasm_bindgen(main)]
doesn't actually call that function when using the init()
function. It only works as expected on fn main
in a binary or example.
I will try to improve this, English isn't my first language, please feel free to suggest better wording.
5806157
to
4436ad7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add an entry for the guide page to guide/src/SUMMARY.md
so that it'll show up in the sidebar.
Er, you didn't actually remove |
657a3c1
to
7320618
Compare
My bad, I forgot to save the file before committing 😆. |
Co-Authored-By: Liam Murphy <[email protected]>
7320618
to
072035b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This PR introduces a new attribute for the
wasm_bindgen
macro:main
.The intention here is to be used on
fn main()
in a Cargo binary or example.Currently
wasm-bindgen
adjusts themain
function to be used on startup anyway, but this attribute has a couple of advantages:async fn main()
in binaries by removing theasync
from the function signature but leaving the requiredfn main()
otherwise intact.main
function will do nothing, this adjusts it to actually properly throw the error.fn main()
are supported, seeTermination
. This is done with the help of autoref-based specialization, see this case study by dtolnay.The ui-tests in CI have been adjusted to test on Rust v1.61 to support
Termination
and it's connectedExitCode
, which is why some unrelated ui-test results had to be adjusted.Replaces #3252.
Replaces #3263.
Fixes #3076.
Fixes #3262.