forked from rustwasm/wasm-bindgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rustwasm/master
Add support for `#[wasm_bindgen]` on `async fn` (rustwasm#1754)
- Loading branch information
Showing
10 changed files
with
236 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub struct MyType; | ||
|
||
#[wasm_bindgen] | ||
pub async fn good1() { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good2() -> JsValue { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good3() -> u32 { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good4() -> MyType { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good5() -> Result<(), JsValue> { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good6() -> Result<JsValue, JsValue> { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good7() -> Result<u32, JsValue> { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good8() -> Result<MyType, JsValue> { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good9() -> Result<MyType, u32> { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn good10() -> Result<MyType, MyType> { loop {} } | ||
|
||
pub struct BadType; | ||
|
||
#[wasm_bindgen] | ||
pub async fn bad1() -> Result<(), ()> { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn bad2() -> Result<(), BadType> { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn bad3() -> BadType { loop {} } | ||
#[wasm_bindgen] | ||
pub async fn bad4() -> Result<BadType, JsValue> { loop {} } | ||
|
||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
error[E0277]: the trait bound `std::result::Result<(), ()>: wasm_bindgen::__rt::IntoJsResult` is not satisfied | ||
--> $DIR/async-errors.rs:29:1 | ||
| | ||
29 | #[wasm_bindgen] | ||
| ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::IntoJsResult` is not implemented for `std::result::Result<(), ()>` | ||
| | ||
= help: the following implementations were found: | ||
<std::result::Result<(), E> as wasm_bindgen::__rt::IntoJsResult> | ||
<std::result::Result<T, E> as wasm_bindgen::__rt::IntoJsResult> | ||
= note: required by `wasm_bindgen::__rt::IntoJsResult::into_js_result` | ||
|
||
error[E0277]: the trait bound `std::result::Result<(), BadType>: wasm_bindgen::__rt::IntoJsResult` is not satisfied | ||
--> $DIR/async-errors.rs:31:1 | ||
| | ||
31 | #[wasm_bindgen] | ||
| ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::IntoJsResult` is not implemented for `std::result::Result<(), BadType>` | ||
| | ||
= help: the following implementations were found: | ||
<std::result::Result<(), E> as wasm_bindgen::__rt::IntoJsResult> | ||
<std::result::Result<T, E> as wasm_bindgen::__rt::IntoJsResult> | ||
= note: required by `wasm_bindgen::__rt::IntoJsResult::into_js_result` | ||
|
||
error[E0277]: the trait bound `wasm_bindgen::JsValue: std::convert::From<BadType>` is not satisfied | ||
--> $DIR/async-errors.rs:33:1 | ||
| | ||
33 | #[wasm_bindgen] | ||
| ^^^^^^^^^^^^^^^ the trait `std::convert::From<BadType>` is not implemented for `wasm_bindgen::JsValue` | ||
| | ||
= help: the following implementations were found: | ||
<wasm_bindgen::JsValue as std::convert::From<&'a T>> | ||
<wasm_bindgen::JsValue as std::convert::From<&'a std::string::String>> | ||
<wasm_bindgen::JsValue as std::convert::From<&'a str>> | ||
<wasm_bindgen::JsValue as std::convert::From<MyType>> | ||
and 62 others | ||
= note: required because of the requirements on the impl of `std::convert::Into<wasm_bindgen::JsValue>` for `BadType` | ||
= note: required because of the requirements on the impl of `wasm_bindgen::__rt::IntoJsResult` for `BadType` | ||
= note: required by `wasm_bindgen::__rt::IntoJsResult::into_js_result` | ||
|
||
error[E0277]: the trait bound `std::result::Result<BadType, wasm_bindgen::JsValue>: wasm_bindgen::__rt::IntoJsResult` is not satisfied | ||
--> $DIR/async-errors.rs:35:1 | ||
| | ||
35 | #[wasm_bindgen] | ||
| ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::__rt::IntoJsResult` is not implemented for `std::result::Result<BadType, wasm_bindgen::JsValue>` | ||
| | ||
= help: the following implementations were found: | ||
<std::result::Result<(), E> as wasm_bindgen::__rt::IntoJsResult> | ||
<std::result::Result<T, E> as wasm_bindgen::__rt::IntoJsResult> | ||
= note: required by `wasm_bindgen::__rt::IntoJsResult::into_js_result` | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters