DEV Community

loading...

Discussion on: Why the Rust module system might be hard to understand

Collapse
u007d profile image
Brad Gibson • Edited

Unfortunately it's not quite so straightforward:

Take for example a file foo.rs:

// filename: foo.rs
pub fn foo() {}

mod bar {
    pub fn bar() {}
}
Enter fullscreen mode Exit fullscreen mode

Above, you have foo.rs defining a foo module AND a bar module--all within 1 file. The author is right, it is confusing for people to pick up.

I was hoping the author would provide a clarifying succinct definition I could use to help new people "get" Rust's module system...

Collapse
dotxlem profile image
Dan Author • Edited

I was hoping the author would provide a clarifying succinct definition I could use to help new people "get" Rust's module system...

I didn't try to provide an explanation because I wasn't sure I could do any better than what I've seen out there already. If there's interest though, maybe it'd be worth giving it a shot!

I'll ping here if I post something :)

Forem Open with the Forem app