From df44809603f4cc5978d099d699c3e42c02b2f4b5 Mon Sep 17 00:00:00 2001 From: Thomas Marches <56929277+ThomasMarches@users.noreply.github.com> Date: Sat, 3 Sep 2022 01:03:46 +0200 Subject: [PATCH 1/2] Implement conversion from pointers for `JsValue` - implemented `From<*mut T>` for `JsValue` - implemented `From<*const T>` for `JsValue` - update CI stderr --- crates/macro/ui-tests/async-errors.stderr | 2 ++ src/lib.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/crates/macro/ui-tests/async-errors.stderr b/crates/macro/ui-tests/async-errors.stderr index 492492a181e..740fd94231d 100644 --- a/crates/macro/ui-tests/async-errors.stderr +++ b/crates/macro/ui-tests/async-errors.stderr @@ -40,6 +40,8 @@ error[E0277]: the trait bound `wasm_bindgen::JsValue: From` is not sati > > > + > + > > and 73 others = note: required because of the requirements on the impl of `Into` for `BadType` diff --git a/src/lib.rs b/src/lib.rs index 2d6ace32639..19a7fe74e6b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -785,6 +785,20 @@ impl<'a> From<&'a str> for JsValue { } } +impl From<*mut T> for JsValue { + #[inline] + fn from(s: *mut T) -> JsValue { + JsValue::from(s as usize) + } +} + +impl From<*const T> for JsValue { + #[inline] + fn from(s: *const T) -> JsValue { + JsValue::from(s as usize) + } +} + if_std! { impl<'a> From<&'a String> for JsValue { #[inline] From 76cc329a5bd6693f2e9fbb5fa1ea9545fa65174a Mon Sep 17 00:00:00 2001 From: nasso Date: Mon, 21 Nov 2022 03:15:08 +0000 Subject: [PATCH 2/2] Update `async-errors.stderr` --- crates/macro/ui-tests/async-errors.stderr | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/macro/ui-tests/async-errors.stderr b/crates/macro/ui-tests/async-errors.stderr index 740fd94231d..f4ebb47842f 100644 --- a/crates/macro/ui-tests/async-errors.stderr +++ b/crates/macro/ui-tests/async-errors.stderr @@ -41,9 +41,7 @@ error[E0277]: the trait bound `wasm_bindgen::JsValue: From` is not sati > > > - > - > - and 73 others + and 75 others = note: required because of the requirements on the impl of `Into` for `BadType` = note: required because of the requirements on the impl of `IntoJsResult` for `BadType` note: required by `into_js_result`