Reputation: 259
I am using rust to provide faster functions to a webapp through WASM. This involves creating a large number of helper functions, and while I can put them all in a single file (lib.rs), it would quickly get cluttered. To that end, I would like to have the following file hierarchy:
|-- src
| |-- lib.rs
| |-- helper1.rs
| |-- helper2.rs
Where a file like helper1.rs
might look like:
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn helper1() {
// Do something useful
}
Upvotes: 0
Views: 185
Reputation: 259
In lib.rs, include:
mod helper1;
mod helper2;
This will make the two helper files get linked in.
Upvotes: 3