Problem I'm having is to include module_a into module_b. Asking chatgpt it gave this solution
my_project/
│── src/
│ │── main.rs (Entry point)
│ │── module_a.rs (Contains functions and structs)
│ │── module_b.rs (Depends on module_a)
│── Cargo.toml
// src/module_a.rs
pub struct Data {
pub value: i32,
}
pub fn show_data(data: &Data) {
println!("Data value: {}", data.value);
}
// src/module_b.rs
use crate::module_a::Data; // Correct way to import from module_a
pub fn process_data() -> Data {
Data { value: 42 }
}
Well, it doesn't work. Keep getting "Could not find module_a
in crate root."