-
Notifications
You must be signed in to change notification settings - Fork 30
features/modules: Expand modules section #5
Conversation
Sorry for the delay in reviewing this, and thanks for another contribution! I have some overall comments that I'll put here rather than on the diff. The explanation of So using Also, just to be clear, the imports of a parent module are not visible to its children: // this is not visible to `inner`
use std::collections::HashMap;
mod inner {
// this is required
use std::collections::HashMap;
pub fn mk_map() -> HashMap<int, int> {
HashMap::new()
}
} While it's true that parent modules often re-export the most important definitions for the top-level (see http://aturon.github.io/style/organization.html for the crate-level version of this), the module hierarchy is also used publicly to organize APIs. I think a good example to draw from in this section is This module structure is part of So, the top-level points are:
Please let me know if the above makes sense. I think that using |
Thanks for the feedback. I think your points are spot-on and they definitely make sense to me. Some of them seem to be a result of poor wording on my part. For example, when I wrote I agree that I was pretty busy today (switched apartments!), but I'll put effort into your suggestions tomorrow. |
Per Aaron Turon's suggestions, this clarifies much of the wording for modules. Additionally, it adds recommendations about: - Module naming - Header ordering - path directives
@aturon I've added updates for your recommendations, as well as a couple of other bits that seemed idiomatic - feel free to pick them apart as you please :) I'll leave the changes as separate commits for now (to preserve discussion history), but I can squash everything together when this is ready if you prefer that. |
Sorry for taking so long to review this -- I've been away on a short vacation. I'm going to merge as-is, and then update with some edits to fix a few minor things. Thanks again for your ongoing contributions! |
features/modules: Expand modules section
@nathantypanski FYI, I've pushed some further edits to the section. |
@aturon Cool, thanks for the update. I think you did a good job with the corrections. |
I'd like some feedback on this sketch of modules patterns. I basically covered the simplest and most common design, but I'm sure there's some gaps in the structure here and there's definitely more material available to touch on.
I also think this should mention
mod foo { /* ... */ }
-style code within a single file. I'm not sure what constitutes a good use case for "inline modules" besides tests, and whether that should be discouraged altogether in favor of "real" modules.All of these are listed [OPEN], this is really tentative and so on, but any feedback would be super helpful.