You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warn of uses of pub in the top-level module of an executable-only target.
Specifically, pub outside of a mod block in any of these files would trigger the lint:
src/main.rs
src/bin/foo.rs
src/bin/foo/main.rs
Advantage
pub suppresses "unused" lints, so inadvertently marking something pub may mask that the user forgot to use it.
pub has no other effect (that I'm aware of) in top-level modules of executable-only targets.
I actually ran into this recently: I work on a project that has several executable targets, and I discovered that two of them were not actually using all of their declared arguments.
Drawbacks
There may be a use for pub inside of an executable-only module that I'm not aware of.
Example
use clap::Parser;#[derive(Parser,Debug)]structArgs{#[arg(short, long)]pubname:String,}
Could be written as:
use clap::Parser;#[derive(Parser,Debug)]structArgs{#[arg(short, long)]name:String,}
The text was updated successfully, but these errors were encountered:
What it does
Warn of uses of
pub
in the top-level module of an executable-only target.Specifically,
pub
outside of amod
block in any of these files would trigger the lint:src/main.rs
src/bin/foo.rs
src/bin/foo/main.rs
Advantage
pub
suppresses "unused" lints, so inadvertently marking somethingpub
may mask that the user forgot to use it.pub
has no other effect (that I'm aware of) in top-level modules of executable-only targets.I actually ran into this recently: I work on a project that has several executable targets, and I discovered that two of them were not actually using all of their declared arguments.
Drawbacks
There may be a use for
pub
inside of an executable-only module that I'm not aware of.Example
Could be written as:
The text was updated successfully, but these errors were encountered: