mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2025-01-01 16:04:51 +03:00
parent
fb5e6e9c06
commit
2d4f36c9da
@ -3061,6 +3061,13 @@ pub mod WebAssembly {
|
|||||||
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
|
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/length)
|
||||||
#[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
|
#[wasm_bindgen(method, getter, js_namespace = WebAssembly)]
|
||||||
pub fn length(this: &Table) -> u32;
|
pub fn length(this: &Table) -> u32;
|
||||||
|
|
||||||
|
/// The `get()` prototype method of the `WebAssembly.Table()` object
|
||||||
|
/// retrieves a function reference stored at a given index.
|
||||||
|
///
|
||||||
|
/// [MDN documentation](
|
||||||
|
#[wasm_bindgen(method, catch, js_namespace = WebAssembly)]
|
||||||
|
pub fn get(this: &Table, index: u32) -> Result<Function, JsValue>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebAssembly.Memory
|
// WebAssembly.Memory
|
||||||
|
@ -127,6 +127,9 @@ fn table_error() {
|
|||||||
fn table() {
|
fn table() {
|
||||||
let table = WebAssembly::Table::new(&get_table_object().into()).unwrap();
|
let table = WebAssembly::Table::new(&get_table_object().into()).unwrap();
|
||||||
assert_eq!(table.length(), 1);
|
assert_eq!(table.length(), 1);
|
||||||
|
|
||||||
|
assert!(table.get(0).is_ok());
|
||||||
|
assert!(table.get(999).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
|
Loading…
Reference in New Issue
Block a user