-
Notifications
You must be signed in to change notification settings - Fork 135
Better documentation for "No more mod.rs" #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Further investigation has caused me to believe that the intended way of having no |
@KiChjang Agree with you. |
It's not clear to me what this ticket means. Could you help point me to what needs to be clarified? |
@steveklabnik It's not clear from the documentation that if you transition from a project that had a |
Do you have any suggestions on what should change? I'm having a hard time seeing how you got to that. I'd still like to improve this though! |
Perhaps instead of saying that Conversations with @ZhangHanDong has informed (or really, reminded) me that this is how Rails imported its modules, so perhaps there is some text in the Rails documentation that we could reference... |
I submitted a PR |
@KiChjang PR have been merged. this issues should be closed. |
Sorry but the documentation is still not clear:
This is ok, but:
Sorry what? It is not clear at all what is in which file. Following the above example it seems to say that Also I would have thought that |
Here is a better way to word it I think:
Assuming that is correct. |
Much clearer, thanks! I think it is probably also worth highlighting the fact that if you want to keep all of your module files in a subdirectory, you still have to use
|
I re-read this chapter again today. These words in this changed section have problem truly. what Timmmm said above's above... is right. The comments for mod decl after "In Rust 2018..."
make no sense ... two files? which files? The fact should be that "mod foo" should be declared in its parent(mod), like in "lib.rs". @Timmmm your above idea is not right. "No more mod.rs" is true. You can have no mod.rs for modules now. I suggest you do some tries. This is why I/we should advocate the 2018 style. So, I suggest to reopen this idea and correct the problem. |
@jinmingjian Have you seen the rewritten version? It is available in the beta or nightly docs: https://doc.rust-lang.org/beta/edition-guide/rust-2018/module-system/path-clarity.html#no-more-modrs This should hit stable next week (it unfortunately takes a while to ride the train to stable). |
@ehuss thanks for pointing this beta edition-guide! It is great! It is interesting to see we do different changes to different versions of the same docs. A little mess... OK, I may live with nightly docs: https://doc.rust-lang.org/nightly/edition-guide/rust-2018/module-system/path-clarity.html#no-more-modrs , rather than fooled by the search engine:smiley:. |
No it isn't. It is "No more mod.rs if you are ok with moving the (former) mod.rs file into its parent directory". To put it another way, "no more mod.rs" implies that there is never any reason to use |
@Timmmm Yes. I eliminate the mod.rs in my project. And in fact, I've seen several big projects done this. OK, YMMV. But I suggest who read this issue can do your own try. |
I've tried both structures (with and without
The section is confusing, as I'm new to rust. Let me clarify.
I have edition 2015,
I have no errors for having
That's why e.g. vscode shows path when several tabs with same names are opened. So if I prefer |
Support for non-mod-rs files was stabilized in both editions in the 1.31 release. You are free to use either style on both editions. Some of the confusion may be because the edition guide was written in such a way that "Rust 2015" meant how code was written around the 1.0 release, and "2018" was how code can be written after the 1.31 release. It sort of provides the highlights of the changes in the 3 years between May 2015 and Dec 2018. It does not necessarily mean certain things can only be done when you declare the edition as "2018". There is a page at https://doc.rust-lang.org/edition-guide/rust-2018/edition-changes.html that explicitly lists the actual differences between the two. |
Ok, I would at least add something like this to the end of this section: Also I would change it's title, since it's misleading ("No more mod.rs"). And lastly it shouldn't state "In Rust 2015..." / "In Rust 2018..." if it is not about edition anyore, but rather compiller version. Maybe something like ""In Rust 2015 (before 1.31)...". |
1、 在Rust 1.30之前使用
|
https://rust-lang-nursery.github.io/edition-guide/rust-2018/module-system/path-clarity.html#no-more-modrs
Emphasis mine. I discovered that this does not mean that
mod.rs
can be eliminated from your projects once and for all -- instead, it means specifically that in the case where you have onlysrc/foo/mod.rs
, you can instead name itsrc/foo.rs
and it'll work just fine.The text was updated successfully, but these errors were encountered: