Skip to content

Recommended style for long method generics. #208

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

Open
konnorandrews opened this issue Mar 15, 2025 · 0 comments
Open

Recommended style for long method generics. #208

konnorandrews opened this issue Mar 15, 2025 · 0 comments

Comments

@konnorandrews
Copy link

In relation to rust-lang/rustfmt#6507,

pub fn cli() -> Command {
    subcommand("uninstall")
        .about("Remove a Rust binary")
-       .arg(
-           Arg::new("spec")
-               .value_name("SPEC")
-               .num_args(0..)
-               .add::<clap_complete::ArgValueCandidates>(clap_complete::ArgValueCandidates::new(
-                   || get_installed_crates(),
-               )),
-       )
+       .arg(Arg::new("spec").value_name("SPEC").num_args(0..).add::<
+           clap_complete::ArgValueCandidates,
+       >(
+           clap_complete::ArgValueCandidates::new(|| get_installed_crates()),
+       ))
        .arg(opt("root", "Directory to uninstall packages from").value_name("DIR"))
        .arg_silent_suggestion()
        .arg_package_spec_simple("Package to uninstall")
        .arg(
            multi_opt("bin", "NAME", "Only uninstall the binary NAME")
                .help_heading(heading::TARGET_SELECTION),
        )
        .after_help(color_print::cstr!(
            "Run `<cyan,bold>cargo help uninstall</>` for more detailed information.\n"
        ))
}

Which of these should be preferred? Rustfmt currently ends up with red because it never wraps method generics. If we allow method generics to wrap then we get cases like green. Should wrapping a chain be preferred over wrapping any of the method generics in the chain?

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

No branches or pull requests

1 participant