This has been a major frustration of mine ever since I discovered the tool, and while I’ve thus far been willing to swallow my disgust for its preferences in favor of the benefits of an autoformatter, moments like this shake my faith. This is what rustfmt wants to do:

-   let peer = self.connected.iter().reduce(|a,b|
-           if key_distance(a.id, recipient) < key_distance(b.id, recipient) { a } else { b }).unwrap();
+   let peer = self
+           .connected
+           .iter()
+           .reduce(|a, b| {
+                   if key_distance(a.id, recipient) < key_distance(b.id, recipient) {
+                           a
+                   } else {
+                           b
+                   }
+           })
+           .unwrap();

It won’t even accept a modest counter-proposal like moving .connected.iter() to the first line. Nor can I find any settings for rustfmt.toml that can change its mind. Please tell me I am not the only one who hates rustfmt.

  • jokeyrhyme@lemmy.ml
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    3 years ago

    I love it

    Having tools that are opinionated about line breaks is amazing for my productivity

    I don’t like exactly what it does every time, but overall I spend so much less time fiddling with whitespace

  • Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    3
    arrow-down
    2
    ·
    3 years ago

    I hate all auto-formatters, if that counts. ¯\_(ツ)_/¯

    I see it as a central part of the craft, to write code that is as easy to understand as possible.
    And good formatting can help the reader to differentiate boilerplate from logic, or to simply tell different contexts apart.

    Auto-formatters throw out that good formatting and replace it with mediocre formatting. They produce code that’s correctly formatted by some robot’s judgement, but shite for humans.

    • nutomic@lemmy.mlM
      link
      fedilink
      arrow-up
      7
      ·
      edit-2
      3 years ago

      They give consistent formatting, which in my opinion is even better once you are used to it.

    • Yujiri@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      Go’s autoformatter has never done anything barabous in my experience, but maybe that’s because it doesn’t deal with breaking lines

  • pinknoise@lemmy.ml
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    3 years ago

    Seems fine to me, maybe the closure definitions could be on new lines. Imo rustfmt is pretty nice, the only thing I really hate is spaces instead of tabs.

    • Yujiri@lemmy.mlOP
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      well, if you want it to use tabs instead of spaces (I do too), you can set hard_tabs = true in rustfmt.toml