数字切片: [u8], [i8], [u16], [i16], [u32], [i32], [u64], [i64], [f32][f64]

T 参数&T 参数&mut T 参数T 返回值Option<&T> 参数Option<T> 返回值JavaScript 表示
Wasm 内存的 JavaScript TypedArray 视图,用于装箱切片的相应类型 (Int32Array, Uint8Array 等)

Rust 示例用法

#![allow(unused)]
fn main() {
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn take_number_slice_by_shared_ref(x: &[f64]) {}

#[wasm_bindgen]
pub fn take_number_slice_by_exclusive_ref(x: &mut [u8]) {}
}

JavaScript 示例用法

import {
  take_number_slice_by_shared_ref,
  take_number_slice_by_exclusive_ref,
} from './guide_supported_types_examples';

take_number_slice_by_shared_ref(new Float64Array(100));
take_number_slice_by_exclusive_ref(new Uint8Array(100));