库 crate
除了拥有 main
函数之外,还可以将你的项目设置为 cdylib
项目。为了做到这一点,请将以下内容添加到你的 Cargo.toml
中
[lib]
crate-type = ["cdylib", "rlib"]
然后,像这样在你的 lib.rs
中定义入口点(不需要是 async
的)
#![allow(unused)] fn main() { #[wasm_bindgen(start)] pub async fn run() {} }
除了拥有 main
函数之外,还可以将你的项目设置为 cdylib
项目。为了做到这一点,请将以下内容添加到你的 Cargo.toml
中
[lib]
crate-type = ["cdylib", "rlib"]
然后,像这样在你的 lib.rs
中定义入口点(不需要是 async
的)
#![allow(unused)] fn main() { #[wasm_bindgen(start)] pub async fn run() {} }