Skip to content
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

Short impl's wrap leaving "where" dangling on a line by itself #1718

Closed
SamWhited opened this issue Jun 17, 2017 · 3 comments
Closed

Short impl's wrap leaving "where" dangling on a line by itself #1718

SamWhited opened this issue Jun 17, 2017 · 3 comments

Comments

@SamWhited
Copy link

SamWhited commented Jun 17, 2017

Consider the following formatting (from the current nightly build as of 2017-06-17) for a generic Set trait:

impl<T> Set<T> for T
where
    T: PartialEq,
{
    default fn contains(&self, c: T) -> bool {
        *self == c
    }
}

This feels unnecessary to me. When it's this short, and could always fit on a line, there's no reason to wrap:

impl<T> Set<T> for T where T: PartialEq,

If we always want to wrap for consistency with longer types, it feels poor to leave the "where" on a line all by itself, the following would look better (and extra generic parameters could still be added underneath and tabbed out to line up with the first one):

impl<T> Set<T> for T
    where T: PartialEq,
@sgrif
Copy link

sgrif commented Jun 17, 2017

This was pretty exhaustively discussed in the RFC: rust-lang/style-team#38

You can always write impl<T: PartialEq> Set<T> instead

@SamWhited
Copy link
Author

SamWhited commented Jun 17, 2017

Thanks; it's hard to find any formatting / code things with GitHub's search. If this is intended then there's no issue. For a simple case like this at least it is suprising and "looks like" a bug to me, but of course, maybe it's just me.

You can always write impl<T: PartialEq> Set instead

I assume where exists for a reason and this would not be practical in all cases, however, in this deliberately minimal example you're right, I could.

@nrc
Copy link
Member

nrc commented Jun 17, 2017

and here rust-lang/style-team#74 too (closing because it is an RFC issue, not a Rustfmt one)

@nrc nrc closed this as completed Jun 17, 2017
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

3 participants