From f88a041fa3fc1ec460ee474df810770dd3544864 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sun, 25 Feb 2024 00:58:27 +0800 Subject: [PATCH] feat(napi): impl chained Into for TypedArray types (#1978) --- .../bindgen_runtime/js_values/arraybuffer.rs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs index 255897ee..9eff82cb 100644 --- a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs +++ b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs @@ -573,3 +573,64 @@ impl>> From for Uint8Array { Uint8Array::new(data.into()) } } + +impl>> From for Uint8ClampedArray { + fn from(data: T) -> Self { + Uint8ClampedArray::new(data.into()) + } +} + +impl>> From for Uint16Array { + fn from(data: T) -> Self { + Uint16Array::new(data.into()) + } +} + +impl>> From for Uint32Array { + fn from(data: T) -> Self { + Uint32Array::new(data.into()) + } +} + +impl>> From for Int8Array { + fn from(data: T) -> Self { + Int8Array::new(data.into()) + } +} + +impl>> From for Int16Array { + fn from(data: T) -> Self { + Int16Array::new(data.into()) + } +} + +impl>> From for Int32Array { + fn from(data: T) -> Self { + Int32Array::new(data.into()) + } +} + +impl>> From for Float32Array { + fn from(data: T) -> Self { + Float32Array::new(data.into()) + } +} + +impl>> From for Float64Array { + fn from(data: T) -> Self { + Float64Array::new(data.into()) + } +} + +#[cfg(feature = "napi6")] +impl>> From for BigInt64Array { + fn from(data: T) -> Self { + BigInt64Array::new(data.into()) + } +} +#[cfg(feature = "napi6")] +impl>> From for BigUint64Array { + fn from(data: T) -> Self { + BigUint64Array::new(data.into()) + } +}