I'm trying to learn rust right now and I'm really struggling with how rust does namespaces, filepaths, or whatever you want to call it. So if I have a file at the root and want to call a method in a file in a subfolder, I can't figure out how. Would you make an in depth guide around namespaces (or whatever it's called) in rust? And if you do, would you let me know?
Professional problem-solver, developing great ideas into solutions with value. Focus on Open Source, .NET, JavaScript/TypeScript, Azure, Web, DevOps, Agile & Leadership.
Yes, Rust's module-system is closer to the module-system in Node.js and quite different from how C# thinks about namespaces, from what I can see so far.
I will cover this in upcoming articles, with more advanced Rust concepts.
not directly on topic but following this (dev.to/qongzi/bevy-minesweeper-int...) 12 part tutorial I now understand much more how the module system work.
notable takeaways:
module can be a single .rs file or a folder with mod.rs file (further describing sub modules).
if you want to use some module in your main.rs file you need to add mod some; on top of your `main.rs.
after the wiring is done you can use types declared in your external module with use some::SomeStruct;
I'm trying to learn rust right now and I'm really struggling with how rust does namespaces, filepaths, or whatever you want to call it. So if I have a file at the root and want to call a method in a file in a subfolder, I can't figure out how. Would you make an in depth guide around namespaces (or whatever it's called) in rust? And if you do, would you let me know?
Yes, Rust's module-system is closer to the module-system in Node.js and quite different from how C# thinks about namespaces, from what I can see so far.
I will cover this in upcoming articles, with more advanced Rust concepts.
not directly on topic but following this (dev.to/qongzi/bevy-minesweeper-int...) 12 part tutorial I now understand much more how the module system work.
notable takeaways:
mod.rs
file (further describing sub modules).some
module in yourmain.rs
file you need to addmod some;
on top of your `main.rs.use some::SomeStruct;
just googled a good article about rust modules: sheshbabu.com/posts/rust-module-sy...