Skip to content

Extended the module tutorial section about files a bit #9398

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 1 commit into from
Sep 23, 2013

Conversation

Kimundi
Copy link
Member

@Kimundi Kimundi commented Sep 22, 2013

No description provided.

@@ -2420,7 +2420,8 @@ However, in practice you usually want to split you code up into multiple source
In order to do that, Rust allows you to move the body of any module into it's own source file, which works like this:

If you declare a module without its body, like `mod foo;`, the compiler will look for the
files `foo.rs` and `foo/mod.rs`. If it finds either, it uses the content of that file as the body of the module.
files `foo.rs` and `foo/mod.rs` inside some directory (usually the same as of the source file containing
Copy link
Member

Choose a reason for hiding this comment

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

"Usually"? When does it not look in the same directory?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's explained further below that section. It will look for those two relative paths in a directory that is the the path of the source file that contains the mod ...;, concatenated with a path build by concatenating all nested mod ... { ... } statrments the mod ...; is contained in.

// src/foo/bar.rs
mod a {
    mod b {
        mod c; // will look for src/foo/a/b/c.rs and src/foo/a/b/c/mod..rs
    }
}

bors added a commit that referenced this pull request Sep 23, 2013
@bors bors closed this Sep 23, 2013
@bors bors merged commit bb7bc6c into rust-lang:master Sep 23, 2013
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.

3 participants