I want to learn Rust, I've taken some courses and I've solved many simple problems by myself using Rust. But that's not enough, so I decided to build a side project.
I wanted to build a git hook, so before I commit my files, the hook will launch, analyze my diffs, found new comments or some other keywords and if the code have these words, it will exit with error code and abort the commit.
I wanted to build this program because when I am getting involved in a new project, I fill the code with many tags and log messages to better understand what is happening underneath the hood. But often I put too many and I forgot to erase some of these tags when committing
I first build the project using my "go to" language, Ruby, and the I copied the project using Rust. Here is the original code on Ruby: GitHub - KarlHeitmann/chuletas_cleanup and here is the clone GitHub - KarlHeitmann/chuletas_warning_hook: A little script in rust desifned to warn you if there are any "cheat sheet" (chuletas or torpedoes in spanish) you are committing in your source code.
On README.md in Ruby there is a large explanation of the project. Both versions are basic and functional. But I want to ask you guys, what could be improved on the Rust code. I used structs, traits, and some few matchers. But I think the code can be refactored much more better. Any feedback on refactorization will be appreciated.
Fun fact: on colloquial spanish, "chuleta" means "cheat sheet", but it is used when you go to an exam on school, and you hide your cheat sheet, or you write on your forearm the formulas for the exam.
There are lot of things that can be improved in this little script (showing the line on the file where the offense is found, add other languages, etc), but right now I am interested in how many different ways I can write this code to do the same thing.
I wanted to build this hook because I wanted to prevent -my- tags, comments and logs being committed, not the previous tags, comments and logs that other people may have put on the source code before.