diff --git a/src/convert/slices.rs b/src/convert/slices.rs index a3cb6ec90b3f..9a4086e742cb 100644 --- a/src/convert/slices.rs +++ b/src/convert/slices.rs @@ -6,6 +6,7 @@ use core::str; use crate::convert::{FromWasmAbi, IntoWasmAbi, RefFromWasmAbi, RefMutFromWasmAbi, WasmAbi}; use crate::convert::{OptionIntoWasmAbi, Stack}; +use crate::JsValue; if_std! { use core::mem; @@ -123,7 +124,7 @@ macro_rules! vectors { } vectors! { - u8 i8 u16 i16 u32 i32 u64 i64 usize isize f32 f64 + u8 i8 u16 i16 u32 i32 u64 i64 usize isize f32 f64 JsValue } if_std! { @@ -202,41 +203,3 @@ impl RefFromWasmAbi for str { str::from_utf8_unchecked(<[u8]>::ref_from_abi(js, extra)) } } - -if_std! { - use crate::JsValue; - - impl IntoWasmAbi for Box<[JsValue]> { - type Abi = WasmSlice; - - #[inline] - fn into_abi(self, extra: &mut Stack) -> WasmSlice { - let ptr = self.as_ptr(); - let len = self.len(); - mem::forget(self); - WasmSlice { - ptr: ptr.into_abi(extra), - len: len as u32, - } - } - } - - impl OptionIntoWasmAbi for Box<[JsValue]> { - fn none() -> WasmSlice { null_slice() } - } - - impl FromWasmAbi for Box<[JsValue]> { - type Abi = WasmSlice; - - #[inline] - unsafe fn from_abi(js: WasmSlice, extra: &mut Stack) -> Self { - let ptr = <*mut JsValue>::from_abi(js.ptr, extra); - let len = js.len as usize; - Vec::from_raw_parts(ptr, len, len).into_boxed_slice() - } - } - - impl OptionFromWasmAbi for Box<[JsValue]> { - fn is_none(slice: &WasmSlice) -> bool { slice.ptr == 0 } - } -}