Skip to content

Document having only src/bin/*.rs binaries is valid #14463

@nekomachi-touge

Description

@nekomachi-touge

Problem

I found the following section of the cargo book could make readers think they must provide src/main.rs.

Binary targets are executable programs that can be run after being compiled.
The default binary filename is `src/main.rs`, which defaults to the name of
the package. Additional binaries are stored in the [`src/bin/`
directory][package layout]. The settings for each binary can be [customized]
in the `[[bin]]` tables in `Cargo.toml`.

However, it is also valid to have only src/bin/*.rs binaries and not to have src/main.rs.
I believe clarifying this situation on the book will help readers when arranging codes for binaries.

Proposed Solution

Changing the section like below should work:

Binary targets are executable programs that can be run after being compiled. 
The default binary filename is `src/main.rs`, which defaults to the name of 
the package. Additionally one or more binaries are stored in the [`src/bin/`
 directory][package layout]. In this case the default binary `src/main.rs` 
is not required. The settings for each binary can be [customized] in the
`[[bin]]` tables in `Cargo.toml`.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documenting-cargo-itselfArea: Cargo's documentationC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions