Run rustfmt --check in CI on push #35
Labels
No labels
complexity
high
complexity
low
complexity
medium
importance
high
importance
low
importance
medium
type
bug
type
chore
type
feature suggestion
type
missing feature
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
thetxt/oxide#35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
rustfmtcan verify whether files are correctly formatted with the--checkflag. It should properly be set up in CI to easily see whether a PR is properly formatted.see my comment on the linked pr #40
First, I agree with you, that
rustfmtis 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 therustfmt::skipattribute.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 :)
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 :/
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
implemented in 0.4.0