Jumping into a Rust project
I mentioned in my previous post that I was going to start working on Supernova, a tool written in Rust for exporting GitHub stars as an organized list. I’ve never looked at or worked with anything written in The Rust Programming Language before, but I wanted to see what it was all about and maybe get some experience with another programming language under my belt.
Unfortunately the fix I worked on did not leave me with much in the department of really exploring and getting familiar with Rust’s nuances in comparison to C++ for example, but it did give me a solid introduction to the syntax and style. I now feel comfortable looking at Rust code, and am more confident in my ability to get involved with more projects written in Rust.
I had no idea what Rust was like before I got involved with Supernova. Luckily, the project had an existing code base small enough to not overwhelm me, and I was able to start digging. First thing I needed to do was figure out how the to run the thing. I followed these instructions which explained some Rust basics as well as how to compile a Rust program. The project had a Cargo file, so I found some more information on what that was and how it worked, and once I was able to successfully build and run the program, I could start looking at and playing with the code.
The fix I chose involved modifying a function to warn the user about their request limitations by extracting specific header information from the response to a GitHub API call. The issue provided me with a great starting point, but I really wanted to understand exactly what the code did before I started making and testing specific changes. I wanted to have a grasp on things before I got going, so I literally started from the beginning and went through the code, line by line, googling things as I went, adding in-line comments for myself on my notes branch. There were some things that seemed too complicated for me to understand given the time I had, so I would just read enough of the docs to get an idea and move on. The main thing for me was to understand the syntax (some of it was quite different from what I’m used to), what method calls were doing, and what was being passed around.
My research tabs primarily consisted of the reqwest crate documentation for insight into the HTTP client methods available, and Rust documentation. I did a lot of back and forth between the components of the code and the documentation, searching for information on methods and objects as needed, until I had a solid grasp and could start implementing changes.
After much trial and error, I finally had something solid to open a pull request with, which at this point in time has been reviewed and is pending my further changes. I received really great feedback and review, with clear direction on how to fix up my code (take a look at my PR for details).
In the process of implementing my changes, I also came across something about conditional requests which Supernova can potentially utilize for optimizing some rate-limiting problems. The project creator liked the find and suggested I open an issue to explore it’s use and possible integration into the code.
Overall, I feel pretty good about this PR. Jumping into a project can be daunting, especially when the language is totally new to you. While it can feel overwhelming at times, I’m slowly learning to start small, and that with patience, time, and google, anything is possible :)