Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It just really depends. I should have been writing these down over the years. A few common points of confusion off the top of my head:

People expecting to put "mod foo;" at the top of foo.rs, to declare that foo.rs is a module.

People expecting to put "mod foo { }" with the contents of the file inside the {}s to declare that foo.rs is a module.

People expecting that "use" declares a module, not "mod."

People expecting every file inside a directory "foo" to be the contents of the "foo" module, regardless of filename, all concatenated together.

People expecting that mod statements never need to exist because it should be inferred from the filesystem.

General confusion about the privacy rules; that "pub" may not mean that your thing is globally public.

General confusion about crates vs modules; main.rs and lib.rs being in the same directory, but declaring different crates. Not understanding how to import stuff from lib.rs into main.rs, because it feels a bit different than other modules.

People used to also struggle a lot with "use" and paths pre-Rust 2018, but that's been mostly cleaned up at this point.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: