We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e106ca3 commit 86937b9Copy full SHA for 86937b9
crates/js-sys/src/lib.rs
@@ -4589,6 +4589,17 @@ macro_rules! arrays {
4589
all_wasm_memory.set(self, offset as u32);
4590
}
4591
4592
+
4593
+ impl<'a> From<&'a [$ty]> for $name {
4594
+ #[inline]
4595
+ fn from(slice: &'a [$ty]) -> $name {
4596
+ // TODO if this was written in JS it could avoid passing the `view` TypedArray to Rust,
4597
+ // which would be more efficient
4598
4599
+ // This is safe because the `new` function makes a copy if its argument is a TypedArray
4600
+ unsafe { $name::new(&$name::view(slice)) }
4601
+ }
4602
4603
)*);
4604
4605
0 commit comments