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

Where clauses #3877

Closed
silvioprog opened this issue Oct 20, 2019 · 3 comments
Closed

Where clauses #3877

silvioprog opened this issue Oct 20, 2019 · 3 comments

Comments

@silvioprog
Copy link

Hi.

Many parts in the Rust documentation shows where clause in front the user type and preserves the left brace in the same line of the fn keyword, e.g:

impl<T> PrintInOption for T where
    Option<T>: Debug {
    fn print_in_option(self) {
        println!("{:?}", Some(self));
    }
}

however, when we format those codes using rustfmt, they looks like this:

impl<T> PrintInOption for T
where
    Option<T>: Debug,
{
    fn print_in_option(self) {
        println!("{:?}", Some(self));
    }
}

Another example. Before formatting:

impl <A, D> MyTrait<A, D> for YourType where
    A: TraitB + TraitC,
    D: TraitE + TraitF {}

After formatting:

impl<A, D> MyTrait<A, D> for YourType
where
    A: TraitB + TraitC,
    D: TraitE + TraitF,
{
}

Notice the where and braces (wrong?) indentation.

I'm not sure if it is by design, so I decided to report that.

Thank you!

P.S.: All code examples was extracted from the official Rust online documentation.

@calebcartwright
Copy link
Member

thanks @silvioprog

extracted from the official Rust online documentation

Are you referring to the Book? If so, I believe that's because they aren't running rustfmt on all the code snippets and examples used there (rust-lang/book#1690 rust-lang/book#2008)

@topecongiro
Copy link
Contributor

@silvioprog This is intentional. As @calebcartwright noted, all the rust code is not formatted by rustfmt yet. Thanks for the report!

@silvioprog
Copy link
Author

Thanks guys. Up-vote for auto-formatting all documentation examples! 😃 👍

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