Skip to content

Middle-ground for wrapping function/macro arguments #1241

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
ssokolow opened this issue Dec 16, 2016 · 1 comment
Open

Middle-ground for wrapping function/macro arguments #1241

ssokolow opened this issue Dec 16, 2016 · 1 comment

Comments

@ssokolow
Copy link

ssokolow commented Dec 16, 2016

A lot of the assert! calls in my code are just too long to fit on a single line, but that "tiny first and last argument, big middle one" structure produces a lot of wasted space for tall layouts.

assert!(1 == 1,
        "12345678901234567890123456789012345678901234567890123456789012345678{}",
        901);

In my Python programs, I resolve this sort of issue by using a word-wrap-esque style like this:

assert!(1 == 1,
        "12345678901234567890123456789012345678901234567890123456789012345678{}", 901);

...or, in rare situations when the above isn't any better, like this...

assert!(1 == 1, "1234567890123456789012345678901234567890123456789012\
        3456789012345678{}", 901);

For asserts of the form "Failed to foo. Got {}", it also has the benefit that the variable name is right next to the substitution placeholder, rather than requiring a full-width visual CRLF.

In Rust, it's annoying to have to throw out rustfmt's attempts to change these every time I run it and it'd be nice if there were some kind of layout option which left them intact.

@nrc nrc added the p-medium label Nov 2, 2017
@nrc
Copy link
Member

nrc commented Nov 2, 2017

cc rust-lang/style-team#86

@scampi scampi added the a-macros label Apr 8, 2019
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