Avatar ·

How to properly split a Rust module into multiple files?

Hello everyone! I started learning Rust and encountered a problem with organizing code in modules. I have a `main.rs` file where I declared the `shapes` module like this: ```rust mod shapes; fn main() { let rect = shapes::Rectangle::new(3.0, 4.0); println!("Area: {}", rect.area()); } ``` In `shapes.rs` I defined structures and functions: ```rust pub struct Rectangle { width: f64, height: f64, } impl Rectangle { pub fn new(w: f64, h: f64) -> Rectangle { Rectangle { width: w, height: h } } pub fn area(&self) -> f64 { self.width * self.height } } ``` Everything works, but now I want to add more shapes: `Circle`, `Triangle`. If I put everything in one `shapes.rs`, the file will become huge. I tried creating a `shapes/` folder