Skip to content

doc/book/crates-and-modules.md: Doesn't explain where it's legal to declare a mod #38514

Closed
@penguin42

Description

@penguin42

Rust wont let me do (all in one src/)

main.rs:
mod image;

image.rs:
mod string; <<<< 'error: cannot declare a new module at this location'

string.rs:
whatever

I don't see anything in crates-and-modules.md that says it's not possible and/or why.
It does let me add the mod string; in the top level main.rs.
(as a new rust user it doesn't make much sense to me why you can't, since main/rs doesn't use string.rs, but image.rs, so why does main.rs care)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions