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

Format a array got a vertical format,It looks too strange #4349

Closed
iamazy opened this issue Jul 24, 2020 · 2 comments
Closed

Format a array got a vertical format,It looks too strange #4349

iamazy opened this issue Jul 24, 2020 · 2 comments
Assignees

Comments

@iamazy
Copy link

iamazy commented Jul 24, 2020

Input

let connect_bytes = &[
            0b0001_0000u8, 49,  // fixed header
            0x00, 0x04, 'M' as u8, 'Q' as u8, 'T' as u8, 'T' as u8, // protocol name
            0x05, // protocol version
            0b1100_1110u8, // connect flag
            0x00, 0x10, // keep alive
            0x05, 0x11, 0x10, // properties
            0x00, 0x03, 'c' as u8, 'i' as u8, 'd' as u8, // client id
            0x05, 0x02, 0x00, 0x00, 0x00, 0x10, // will properties
            0x00, 0x04, 'w' as u8, 'i' as u8, 'l' as u8, 'l' as u8, // will topic
            0x00, 0x01, 'p' as u8, // will payload
            0x00, 0x06, 'i' as u8, 'a' as u8, 'm' as u8, 'a' as u8, 'z' as u8, 'y' as u8, // username
            0x00, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
];

Output

let connect_bytes = &[
            0b0001_0000u8,
            52, // fixed header
            0x00,
            0x04,
            'M' as u8,
            'Q' as u8,
            'T' as u8,
            'T' as u8,     // protocol name
            0x05,          // protocol version
            0b1100_1110u8, // connect flag
            0x00,
            0x10, // keep alive
            0x05,
            0x11,
            0x00,
            0x00,
            0x00,
            0x10, // connect properties
            0x00,
            0x03,
            'c' as u8,
            'i' as u8,
            'd' as u8, // client id
            0x05,
            0x02,
            0x00,
            0x00,
            0x00,
            0x10, // will properties
            0x00,
            0x04,
            'w' as u8,
            'i' as u8,
            'l' as u8,
            'l' as u8, // will topic
            0x00,
            0x01,
            'p' as u8, // will payload
            0x00,
            0x06,
            'i' as u8,
            'a' as u8,
            'm' as u8,
            'a' as u8,
            'z' as u8,
            'y' as u8, // username
            0x00,
            0x06,
            0x01,
            0x02,
            0x03,
            0x04,
            0x05,
            0x06,
];

Expected output
I dont't think the follow code format is right, but at least it doesn't look strange

let connect_bytes = &[
            0b0001_0000u8, 49,  // fixed header
            0x00, 0x04, 'M' as u8, 'Q' as u8, 'T' as u8, 'T' as u8, // protocol name
            0x05, // protocol version
            0b1100_1110u8, // connect flag
            0x00, 0x10, // keep alive
            0x05, 0x11, 0x10, // properties
            0x00, 0x03, 'c' as u8, 'i' as u8, 'd' as u8, // client id
            0x05, 0x02, 0x00, 0x00, 0x00, 0x10, // will properties
            0x00, 0x04, 'w' as u8, 'i' as u8, 'l' as u8, 'l' as u8, // will topic
            0x00, 0x01, 'p' as u8, // will payload
            0x00, 0x06, 'i' as u8, 'a' as u8, 'm' as u8, 'a' as u8, 'z' as u8, 'y' as u8, // username
            0x00, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
];

Meta

  • rustfmt version: rustfmt 1.4.16-stable (939e164 2020-06-11)
  • From where did you install rustfmt?: rustup component add rustfmt
@ayazhafiz
Copy link
Contributor

related: #4146, #2010

however I think it is unlikely for rustfmt to ever do exactly what you want here unless there is an option to group lines by comments, which seems like a niche use case. I think the best thing to do here is to attach a [rustfmt::skip] attribute.

@iamazy
Copy link
Author

iamazy commented Jul 24, 2020

Got it, Thanks

@iamazy iamazy closed this as completed Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants