Is there some way to make "cargo fmt" stop doing this?

Array initializations are spread out over far too many lines by "cargo fmt". Any workaround?

let expected = vec![
    LLVector3 {
        x: -0.5,
        y: -0.5,
        z: -0.5,
    },
    LLVector3 {
        x: -0.5,
        y: -0.5,
        z: 0.5,
    },
    LLVector3 {
        x: 0.5,
        y: -0.5,
        z: -0.5,
    },
   ...
3 Likes

You can put #[rustfmt::skip] on the line before the declaration and format it manually however you want.

1 Like

Maybe you can fine tune the width config options to get the desired results:
https://rust-lang.github.io/rustfmt/?version=master&search=#array_width
https://rust-lang.github.io/rustfmt/?version=master&search=#width_heuristics

1 Like

It seems fmt has no intermediate stops for list of items between "All on one line" and "one element per line". You can tweak settings to get one or the other. But you can't, as far as I can tell, get something comparable to word wrap, with as many elements per line as will fit.

Ugh, looks like the documentation page is buggy. It briefly flashes the correct section and then goes on to ignore the version GET parameter, defaulting to the latest 1.4 version and hiding those two options, along with others that are only available on master :neutral_face:

Yes, sorry should have checked the version. I also noticed that the checkbox stable needs to be checked to get the available parameters for the stable release version. Maybe it's simpler then to use cargo fmt -- --help=config. But yeah, we have to wait for a future release to get more options :slightly_frowning_face: