On Learning Rust
We all have our moments when we want to learn something cool. It struck me this evening and I decided to pick up Rust again. It feels more natural this time due to my more extended knowledge of systems engineering. Now std::program::exit(1) doesn’t seem like Rust magic anymore but a standard way programs should exit gracefully. So I decided to implement Two Pointers in Rust. Boy did I forget what two pointers was. I had to ask GPT to describe two pointers in 10 words. It said something along the lines of, find two numbers in a list that sum to a target number. Now, I chose to design my program to receive all the inputs as program args. The first thing I learnt to do was collect a program’s inputs. Luckily Rust has a handy way in the standard library: std::env::args().collect(). This creates a vector of all passed arguments. Now the next thing to learn was how to parse the collected arguments. Rust prefers pattern matching to for-loops. So I picked up this piece of code from ChatGPT: ...