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

Feature request: Add an option to place the arguments of function-like attributes on the same line until attr_fn_like_width is exceeded. #6301

Open
mamekoro opened this issue Aug 29, 2024 · 0 comments

Comments

@mamekoro
Copy link

When there are many arguments in the #[derive(...)] attribute, placing one argument per line makes the code vertically long and difficult to read.

Could you consider adding an option to place the arguments on the same line until the attr_fn_like_width is exceeded, as shown in the example below?

Example

Current behaviour (rustfmt 1.7.0-stable (3f5fd8d 2024-08-06)):

use derive_more::{
    Add, AddAssign, AsMut, AsRef, Deref, DerefMut, Div, DivAssign, From, Into, Mul, MulAssign, Neg,
    Rem, RemAssign, Sub, SubAssign,
};

#[repr(transparent)]
#[derive(
    Copy,
    Clone,
    Debug,
    PartialEq,
    PartialOrd,
    Deref,
    DerefMut,
    Neg,
    Add,
    AddAssign,
    Sub,
    SubAssign,
    Mul,
    MulAssign,
    Div,
    DivAssign,
    Rem,
    RemAssign,
    From,
    Into,
    AsRef,
    AsMut,
)]
pub struct Meters(pub f32);

fn main() {}

Expected behaviour (when attr_fn_like_width=70):

use derive_more::{
    Add, AddAssign, AsMut, AsRef, Deref, DerefMut, Div, DivAssign, From, Into, Mul, MulAssign, Neg,
    Rem, RemAssign, Sub, SubAssign,
};

#[repr(transparent)]
#[derive(
    Copy, Clone, Debug, PartialEq, PartialOrd, Deref, DerefMut, Neg,
    Add, AddAssign, Sub, SubAssign, Mul, MulAssign, Div, DivAssign,
    Rem, RemAssign, From, Into, AsRef, AsMut,
)]
pub struct Meters(pub f32);

fn main() {}
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

2 participants