diff --git a/src/lib.rs b/src/lib.rs index d2dd2f2b226..0a0d134cc0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1953,18 +1953,18 @@ impl From for JsValue { macro_rules! typed_arrays { ($($ty:ident $ctor:ident $clamped_ctor:ident,)*) => { $( - impl From> for JsValue { - fn from(mut vec: Vec<$ty>) -> Self { - let result = unsafe { JsValue::_new($ctor(vec.as_mut_ptr(), vec.len())) }; - mem::forget(vec); + impl From> for JsValue { + fn from(mut vector: Box<[$ty]>) -> Self { + let result = unsafe { JsValue::_new($ctor(vector.as_mut_ptr(), vector.len())) }; + mem::forget(vector); result } } - impl From>> for JsValue { - fn from(mut vec: Clamped>) -> Self { - let result = unsafe { JsValue::_new($clamped_ctor(vec.as_mut_ptr(), vec.len())) }; - mem::forget(vec); + impl From>> for JsValue { + fn from(mut vector: Clamped>) -> Self { + let result = unsafe { JsValue::_new($clamped_ctor(vector.as_mut_ptr(), vector.len())) }; + mem::forget(vector); result } } @@ -2011,3 +2011,12 @@ where JsValue::from(vector.into_boxed_slice()) } } + +impl From>> for JsValue +where + JsValue: From>>, +{ + fn from(vector: Clamped>) -> Self { + JsValue::from(Clamped(vector.0.into_boxed_slice())) + } +}