Skip to content

rustfmt-formattable syntax? #35

@coolreader18

Description

@coolreader18

I'm aware how minimal and stable this crate is and has been for a long time, but something that's always put me off from using it (usually in favor of manual #[cfg] attributes) is how its syntax is completely unfamiliar to rustfmt, and therefore any expressions or items inside of a cfg_if! block can't get the advantages that rustfmt brings.

// stays as is when `cargo fmt` is run
cfg_if! {
    if #[cfg(foobar)] {
        fn baz() { qux();   flop()
        }
    }
    else {
        fn bar() {
        }
    }
}

Was there a reason that you didn't choose a more traditional/valid rust syntax for the macro? e.g.

cfg_if!(if cfg!(foobar) {
    fn baz() {
        qux();
        flop()
    }
} else {
    fn bar() {}
});

I'm aware that rustfmt wasn't as popular/well-integrated in 2017, but I feel like a syntax like this would greatly improve the ergonomics of this crate.

(feel free to ignore, I was just surprised that there wasn't an issue about this already)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions