Struct Float16Array
#[repr(transparent)]
pub struct Float16Array { /* private fields */ }
Implementations
impl Float16Array
fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> Float16ArrayThe
Float16Array()constructor creates an array with the given buffer but is a view starting atbyte_offset.
impl Float16Array
fn buffer(&self) -> ArrayBufferThe buffer accessor property represents the
ArrayBufferreferenced by aTypedArrayat construction time.
impl Float16Array
fn for_each_as_f32(&self, callback: &mut impl FnMut(f32, u32, Float16Array) + MaybeUnwindSafe)The
forEach()method executes a provided function once per array element, passing values asf32.
impl Float16Array
fn byte_length(&self) -> u32The byteLength accessor property represents the length (in bytes) of a typed array.
impl Float16Array
fn at_as_f32(&self, idx: i32) -> Option<f32>Gets the value at
idxas anf32, counting from the end if negative.
impl Float16Array
fn set_index_from_f32(&self, idx: u32, value: f32)Sets the value at
idxfrom anf32, equivalent to JavaScriptarr[idx] = value.
impl Float16Array
fn new(constructor_arg: &JsValue) -> Float16ArrayThe
Float16Array()constructor creates a new array.
impl Float16Array
fn new_with_byte_offset_and_length(buffer: &JsValue, byte_offset: u32, length: u32) -> Float16ArrayThe
Float16Array()constructor creates an array with the given buffer but is a view starting atbyte_offsetforlengthelements.
impl Float16Array
fn subarray(&self, begin: u32, end: u32) -> Float16ArrayThe
subarray()method returns a newTypedArrayon the sameArrayBufferstore and with the same element types as this array.
impl Float16Array
fn try_for_each_as_f32(&self, callback: &mut impl FnMut(f32, u32, Float16Array) -> Result<(), JsError> + MaybeUnwindSafe) -> Result<(), JsValue>The
forEach()method executes a provided function once per array element, passing values asf32.
impl Float16Array
fn byte_offset(&self) -> u32The byteOffset accessor property represents the offset (in bytes) of a typed array from the start of its
ArrayBuffer.
impl Float16Array
fn copy_within(&self, target: i32, start: i32, end: i32) -> Float16ArrayThe
copyWithin()method shallow copies part of a typed array to another location in the same typed array and returns it, without modifying its size.
impl Float16Array
fn new_from_u16_slice(slice: &[u16]) -> Float16ArrayCreates an array from raw IEEE 754 binary16 bit patterns.
This pairs naturally with the optional
halfcrate:use half::f16; use js_sys::Float16Array; let values = [f16::from_f32(1.0), f16::from_f32(-2.0)]; let bits = values.map(f16::to_bits); let array = Float16Array::new_from_u16_slice(&bits);fn copy_to_u16_slice(&self, dst: &mut [u16])Copy the raw IEEE 754 binary16 bit patterns from this JS typed array into the destination Rust slice.
Panics
This function will panic if this typed array's length is different than the length of the provided
dstarray.Values copied into
dstcan be converted back intohalf::f16withhalf::f16::from_bits.fn copy_from_u16_slice(&self, src: &[u16])Copy raw IEEE 754 binary16 bit patterns from the source Rust slice into this JS typed array.
Panics
This function will panic if this typed array's length is different than the length of the provided
srcarray.When using the optional
halfcrate, populatesrcwithhalf::f16::to_bits().fn to_u16_vec(&self) -> Vec<u16>Efficiently copies the contents of this JS typed array into a new Vec of raw IEEE 754 binary16 bit patterns.
This makes it easy to round-trip through the optional
halfcrate:use half::f16; let bits = array.to_u16_vec(); let values: Vec<f16> = bits.into_iter().map(f16::from_bits).collect();
impl Float16Array
fn new_with_length(length: u32) -> Float16ArrayThe
Float16Array()constructor creates an array with an internal buffer large enough forlengthelements.
impl Float16Array
fn fill_with_f32(&self, value: f32, start: u32, end: u32) -> Float16ArrayThe
fill()method fills all elements from a start index to an end index with a staticf32value.
impl Float16Array
fn slice(&self, begin: u32, end: u32) -> Float16ArrayThe
slice()method returns a shallow copy of a portion of a typed array into a new typed array object.
impl Float16Array
fn length(&self) -> u32The length accessor property represents the length (in elements) of a typed array.
impl Float16Array
fn set(&self, src: &JsValue, offset: u32)The
set()method stores multiple values in the typed array, reading input values from a specified array.
impl Float16Array
fn get_index_as_f32(&self, idx: u32) -> f32Gets the value at
idxas anf32, equivalent to JavaScriptarr[idx].
Trait Implementations
impl AsRef<Float16Array> for Float16Array
fn as_ref(&self) -> &Float16Array
impl AsRef<JsValue> for Float16Array
fn as_ref(&self) -> &JsValue
impl AsRef<Object> for Float16Array
fn as_ref(&self) -> &Object
impl Clone for Float16Array
fn clone(&self) -> Self
impl Debug for Float16Array
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Float16Array
fn default() -> Self
impl Deref for Float16Array
type Target = Object;fn deref(&self) -> &Object
impl ErasableGeneric for Float16Array
type Repr = JsValue;
impl From<JsValue> for Float16Array
fn from(obj: JsValue) -> Self
impl FromWasmAbi for Float16Array
type Abi = <JsValue as FromWasmAbi>::Abi;unsafe fn from_abi(js: Self::Abi) -> Self
impl IntoJsGeneric for Float16Array
where
Float16Array: JsGeneric,
type JsCanon = Float16Array;fn to_js(self) -> Float16Array
impl IntoWasmAbi for Float16Array
type Abi = <JsValue as IntoWasmAbi>::Abi;fn into_abi(self) -> Self::Abi
impl JsCast for Float16Array
fn instanceof(val: &JsValue) -> boolfn unchecked_from_js(val: JsValue) -> Selffn unchecked_from_js_ref(val: &JsValue) -> &Self
impl LongRefFromWasmAbi for Float16Array
type Abi = <JsValue as LongRefFromWasmAbi>::Abi;type Anchor = Float16Array;unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
impl OptionFromWasmAbi for Float16Array
fn is_none(abi: &Self::Abi) -> bool
impl OptionIntoWasmAbi for Float16Array
fn none() -> Self::Abi
impl Promising for Float16Array
type Resolution = Float16Array;
impl RefFromWasmAbi for Float16Array
type Abi = <JsValue as RefFromWasmAbi>::Abi;type Anchor = ManuallyDrop<Float16Array>;unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
impl TypedArray for Float16Array
impl UpcastFrom<Float16Array> for Float16Array
impl WasmDescribe for Float16Array
fn describe()