Closed
Description
I wanted to access the JS console as console::log
, so I attempted this:
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
extern crate wasm_bindgen;
mod console {
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
#[wasm_bindgen(js_namespace = console)]
pub fn log(s: &str);
}
}
The compiler had this warning:
Compiling imaj v0.1.0 (file:///private/tmp/imaj)
warning: function is marked #[no_mangle], but not exported
--> src/lib.rs:12:5
|
12 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^
|
= note: #[warn(private_no_mangle_fns)] on by default
And wasm-bindgen
had this to say:
$ wasm-bindgen target/wasm32-unknown-unknown/release/imaj.wasm --out-dir=.
thread 'main' panicked at 'failed to run export: Function("Module doesn\'t have export __wbindgen_describe___wbg_f_log_log_n")', libcore/result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Making the console
module public worked, but it wasn't my goal to make it public.
rustc 1.27.0-nightly (acd3871ba 2018-05-10)
wasm-bindgen 0.2.10
See also #159
Metadata
Metadata
Assignees
Labels
No labels