【发布时间】:2018-11-18 18:11:06
【问题描述】:
我有兴趣通过rust-webpack-template 使用wasm-bindgen 将Rust 代码编译为WebAssembly。但是,我想避免直接用#[wasm_bindgen] 属性宏直接包装我的代码,这样我就可以从生成的WebAssembly 接口中分离出功能逻辑,从而更好地组织我的项目。相反,我希望将绑定生成放在单独的文件中,例如:
mod my_code;
use my_code::my_function;
#[wasm_bindgen]
my_function; // I want to do something like this!
我知道#[wasm_bindgen] 是一个宏属性,它对通常遵循的函数定义的 AST 进行操作,但是有没有一种方法可以将该宏应用于其他地方定义的代码?
【问题讨论】:
标签: rust rust-macros wasm-bindgen