Logo
Explore Help
Sign In
fluencelabs/wasm-bindgen
1
0
Fork 0
You've already forked wasm-bindgen
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-05-09 04:22:16 +00:00
Code Issues Projects Releases Wiki Activity
wasm-bindgen/tests/wasm/rethrow.js

15 lines
255 B
JavaScript
Raw Normal View History

Allow returning `Result` from functions This commit adds support for exporting a function defined in Rust that returns a `Result`, translating the `Ok` variant to the actual return value and the `Err` variant to an exception that's thrown in JS. The support for return types and descriptors was rejiggered a bit to be a bit more abstract and more well suited for this purpose. We no longer distinguish between functions with a return value and those without a return value. Additionally a new trait, `ReturnWasmAbi`, is used for converting return values. This trait is an internal implementation detail, however, and shouldn't surface itself to users much (if at all). Closes #841
2018-09-17 18:26:45 -07:00
const wasm = require('wasm-bindgen-test.js');
const assert = require('assert');
exports.call_throw_one = function() {
try {
wasm.throw_one();
} catch (e) {
assert.strictEqual(e, 1);
}
};
exports.call_ok = function() {
wasm.nothrow();
};
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.7 Page: 71ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API