I've been trying to follow Rust modules confusion when there is main.rs and lib.rs but without success
My Cargo.toml
[package]
name = "wasm_jd"
version = "0.1.0"
edition = "2021"
src/lib.rs
use serde_json::json;
use serde_json::Value;
use Value::*;
pub fn preview(contracted: Vec<&str>, json: Value) -> Value {
// contracted is read only in the rest of the code
convert(&contracted, "", &json)
}
...
src/main.rs
use serde_json::json;
use serde_json::Value;
use wasm_jd::preview;
fn main() {
let j: Value = json!({"a": 1});
let tmp: Value = preview(Vec::new(), j);
let d = tmp.to_string();
println!("{}", d)
}
When I do cargo run
I get
error[E0432]: unresolved import `wasm_jd`
--> src/main.rs:3:5
|
3 | use wasm_jd::preview;
| ^^^^^^^ use of undeclared crate or module `wasm_jd`
As far as I can see the names match up correctly so I'm very confused?