File tree 2 files changed +6
-8
lines changed
guide/src/reference/attributes/on-rust-exports
2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 1
1
# ` main `
2
2
3
- When attached to the ` fn main() ` function this attribute will adjust it to
4
- properly throw errors if they can be. This is only intended to be used for
5
- binaries.
3
+ When attached to the ` main ` function this attribute will adjust it to properly
4
+ throw errors if they can be.
6
5
7
6
``` rust
8
7
#[wasm_bindgen(main)]
@@ -21,10 +20,9 @@ async fn main() {
21
20
}
22
21
```
23
22
24
- Unlike ` #[wasm_bindgen(start)] ` this will not export a function to be executed
25
- on startup, it should only be used in Cargo binaries or examples for the ` main `
26
- function. ` #[wasm_bindgen(start)] ` will prevent the ` main ` function to start and
27
- should not be used in conjunction.
23
+ This attribute is intended to be used on the ` main ` function of binaries or
24
+ examples only. Unlike ` #[wasm_bindgen(start)] ` , it will not cause a function to
25
+ be executed on start in a library.
28
26
29
27
Any return value that is supported by Rust is supported here, see
30
28
[ ` Termination ` ] . In order, wasm-bindgen will first detect a
Original file line number Diff line number Diff line change @@ -1761,7 +1761,7 @@ pub mod __rt {
1761
1761
#[ inline]
1762
1762
fn __wasm_bindgen_main ( & mut self ) {
1763
1763
if let Err ( e) = self . 0 . take ( ) . unwrap ( ) {
1764
- crate :: throw_val ( std:: format!( "{:?}" , e) . into ( ) ) ;
1764
+ crate :: throw_str ( & std:: format!( "{:?}" , e) ) ;
1765
1765
}
1766
1766
}
1767
1767
}
You can’t perform that action at this time.
0 commit comments