mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 15:01:23 +00:00
Adding in From impl for TypedArrays
This commit is contained in:
@ -4589,6 +4589,17 @@ macro_rules! arrays {
|
|||||||
all_wasm_memory.set(self, offset as u32);
|
all_wasm_memory.set(self, offset as u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> From<&'a [$ty]> for $name {
|
||||||
|
#[inline]
|
||||||
|
fn from(slice: &'a [$ty]) -> $name {
|
||||||
|
// TODO if this was written in JS it could avoid passing the `view` TypedArray to Rust,
|
||||||
|
// which would be more efficient
|
||||||
|
|
||||||
|
// This is safe because the `new` function makes a copy if its argument is a TypedArray
|
||||||
|
unsafe { $name::new(&$name::view(slice)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
)*);
|
)*);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user