Run rustfmt --check in CI on push #35

Closed
opened 2025-12-07 18:30:06 +01:00 by cactusdualcore · 5 comments

I noticed that your code sometimes looks like it wasn't formatted by rustfmt.

There are some very long lines which make reading pretty hard. rustfmt can verify whether files are correctly formatted with the --check flag. It should properly be set up in CI to easily see whether a PR is properly formatted.

I noticed that your code sometimes looks like it wasn't formatted by `rustfmt`. There are some _very_ long lines which make reading pretty hard. `rustfmt` can verify whether files are correctly formatted with the `--check` flag. It should properly be set up in CI to easily see whether a PR is properly formatted.
Owner

see my comment on the linked pr #40

see my comment on the linked pr #40
Author

First, I agree with you, that rustfmt is not ideal. Heck, even Linus Torvalds thinks so!

However, I strongly ask you to reconsider this! Not because of personal preference, but because not using it will impede your ability to write - and more importantly - learn to write Rust. This isn't about code formatting; it's about idiomatic use of the language. Let me try to explain with a metaphor:

I decide to learn a new language. I go to a bookstore, grab myself a dictionary or two, and a full breakdown of that languages grammar, so that I can spend the next few weeks of my life in my basement, obsessively learning new words and grammar rules. After a few months or so, I finally resurface, knowing more words than I will ever need, and able to construct the most niche grammatical constructs anybody could ask of me. So I visit a distant country to use my new language skills! But oh no! I barely seem to understand what other people say. Why is that?

Languages, including programming languages (and imho, even more so!) are more than just vocabulary and grammar. Mannerisms, colloquial use and patterns of use are arguably much, much more important than both of the above combined. In programming language speak, we're talking about idiomatic use. This includes reading idiomatically formatted code, i.e. one that was formatted by rustfmt. And if one particular example is exceptionally egregious, there is always the rustfmt::skip attribute.

What am I really trying to say here? Your code is very much "bad" Rust code. It is not necessarily bad code in general, it just doesn't fit the mannerisms and usage patterns I, or anyone for that matter, are familiar with for a Rust codebase. And familiarity here is a key concept, because it decides how fast and well I can review code, recommend improvements and pinpoint bugs. Furthermore, by not adopting rustfmt, you are actively making it harder for you to improve at writing Rust code.

I highly recommend reading the source of popular Rust crates to familiarize yourself with idiomatic Rust code. This repository greatly reminds me of a weird mixture between C++, some scripting language (e.g. Python) and Rust. You use a lot of patterns commonly associated with beginners in Rust, but don't seem move past them (as they still persist in recent videos and the 0.4.0 rewrite). I don't want to blame you for this, neither do I think this is particularly bad per se. You are, however, isolating yourself in style from the wider Rust community and falling for the trap of the Expert Beginner.

I hope you don't take this as me lecturing or blaming you, or telling you your code sucks (it does not!). I genuinely want to help you learn and improve when it comes to Rust specifically. If you want, we can discuss on discord the numerous places, where and why code is unidiomatic, what can be done to improve it and why you should care about them.

Have a nice day :)

First, I agree with you, that `rustfmt` is not ideal. Heck, even [Linus Torvalds](https://youtu.be/3EeuUui9tzw?si=U4IWbpbohJxuHko4&t=144) thinks so! _However,_ I strongly ask you to reconsider this! Not because of personal preference, but because not using it *will* impede your ability to write - and more importantly - learn to write Rust. This isn't about code formatting; it's about idiomatic use of the language. Let me try to explain with a metaphor: I decide to learn a new language. I go to a bookstore, grab myself a dictionary or two, and a full breakdown of that languages grammar, so that I can spend the next few weeks of my life in my basement, obsessively learning new words and grammar rules. After a few months or so, I finally resurface, knowing more words than I will ever need, and able to construct the most niche grammatical constructs anybody could ask of me. So I visit a distant country to use my new language skills! But oh no! I barely seem to understand what other people say. Why is that? Languages, including programming languages (and imho, even more so!) are more than just vocabulary and grammar. Mannerisms, colloquial use and patterns of use are arguably much, _much_ more important than both of the above _combined_. In programming language speak, we're talking about idiomatic use. This includes reading _idiomatically formatted_ code, i.e. one that was formatted by `rustfmt`. And if one particular example is exceptionally egregious, there is always the `rustfmt::skip` attribute. What am I really trying to say here? Your code is very much "bad" _Rust_ code. It is not necessarily bad code in general, it just doesn't fit the mannerisms and usage patterns I, or anyone for that matter, are _familiar_ with for a Rust codebase. And familiarity here is a key concept, because it decides how fast and well I can review code, recommend improvements and pinpoint bugs. Furthermore, by _not_ adopting `rustfmt`, you are actively making it harder for you to improve at writing Rust code. I highly recommend reading the source of popular Rust crates to familiarize yourself with idiomatic Rust code. This repository greatly reminds me of a weird mixture between C++, some scripting language (e.g. Python) and Rust. You use a lot of patterns commonly associated with beginners in Rust, but don't seem move past them (as they still persist in recent videos and the 0.4.0 rewrite). I don't want to blame you for this, neither do I think this is particularly bad _per se_. You are, however, isolating yourself in style from the wider Rust community and falling for the trap of the [Expert Beginner](https://daedtech.com/how-developers-stop-learning-rise-of-the-expert-beginner/). I hope you don't take this as me lecturing or blaming you, or telling you your code sucks (it does not!). I _genuinely_ want to help you learn and improve when it comes to Rust specifically. If you want, we can discuss on discord the numerous places, where and why code is unidiomatic, what can be done to improve it and why you should care about them. Have a nice day :)
Author

I know this not a goal of this project, but non-idiomatic code also deters people from contributing or trying to understand your code. The former will usually kill a project long term, the latter would be kinda sad because this project is deliberately open :/

I know this not a goal of this project, but non-idiomatic code also deters people from contributing or trying to understand your code. The former will usually kill a project long term, the latter would be kinda sad because this project is deliberately open :/
Owner

added a rustfmt config and ran it on the repo, will see if it annoys me too much and add the CI check if it doesnt

added a rustfmt config and ran it on the repo, will see if it annoys me too much and add the CI check if it doesnt
thetxt added this to the 0.4.0 milestone 2025-12-09 17:19:38 +01:00
thetxt referenced this issue from a commit 2026-01-18 12:56:50 +01:00
Owner

implemented in 0.4.0

implemented in 0.4.0
Sign in to join this conversation.
No description provided.