Skip to content

Clearer documentation for "No more mod.rs" #107

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

Merged
merged 3 commits into from
Sep 24, 2018

Conversation

ZhangHanDong
Copy link
Contributor

No more mod.rs

In Rust 2015, if you have a submodule:

///  foo.rs 
///  or 
///  foo/mod.rs

mod foo;

It can live in foo.rs or foo/mod.rs. If it has submodules of its own, it
must be foo/mod.rs. So a bar submodule of foo would live at
foo/bar.rs.

In Rust 2018, mod.rs is no longer needed.

///  foo.rs 
///  foo/bar.rs

mod foo;

/// in foo.rs
mod bar;

foo.rs can just be foo.rs,
and the submodule is still foo/bar.rs. This eliminates the special
name, and if you have a bunch of files open in your editor, you can clearly
see their names, instead of having a bunch of tabs named mod.rs.

### No more `mod.rs`

In Rust 2015, if you have a submodule:

```rust,ignore
///  foo.rs 
///  or 
///  foo/mod.rs

mod foo;
```

It can live in `foo.rs` or `foo/mod.rs`. If it has submodules of its own, it
*must* be `foo/mod.rs`. So a `bar` submodule of `foo` would live at
`foo/bar.rs`.


In Rust 2018, `mod.rs` is no longer needed. 

```rust,ignore
///  foo.rs 
///  foo/bar.rs

mod foo;

/// in foo.rs
mod bar;
```

`foo.rs` can just be `foo.rs`,
and the submodule is still `foo/bar.rs`. This eliminates the special
name, and if you have a bunch of files open in your editor, you can clearly
see their names, instead of having a bunch of tabs named `mod.rs`.
Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you so much! Some whitespace cleanup and this is good to merge.

Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@steveklabnik steveklabnik merged commit cbdf707 into rust-lang:master Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants