4 ms·
As a rust noob, I gotta say the biggest thing for me for entering the language is how strange the module system works. I still don't fully understand how import
by robust-cactus 4y ago
As a rust noob, I gotta say the biggest thing for me for entering the language is how strange the module system works. I still don't fully understand how importing a module works nor defining one.
It doesn't work like many other languages I'm used to.
- lolinder 4y agoI'm also just getting into Rust and I've loved the module system so far. I'm coming mostly from Java, Kotlin, Python, and TypeScript, which are all rather weak when it comes to modules. In comparison, I like that Rust treats modules as an organizational unit rather than just a side effect of file/folder structure, and I think they manage to do it in a way that isn't overly hard to navigate.
- bool3max 4y agoIMO the module system is explained very well in the book. Read it carefully once or twice, experiment a little, and you're golden.
- Fiahil 4y agoA mod.rs is exactly like a __init__.py. Except Rust removed a couple of annoying edge cases that are present in Python.
- pornel 4y agoThe best mental model is that `mod` works exactly like `fn`, `struct`, and `enum` — creates a new named item in its location.
- egberts1 4y agowhat is stranger still is the compiler-generated symbols that mimic C++. or that exception is weirdly handled. Jury is still out on Rust being incorporated into the Linux kernel because of the above mentions.