I'm Really Enjoying Learning Rust
So far, at least, I am truly enjoying the whole process of learning Rust. It has been a long time since even attempting to learn a new language has been so fun! Maybe it’s because I have a goal in mind. I have both smaller and larger goals envisioned.
My first one was to create a program to solve our only active puzzle cache. It took me about a day and a half to get it functional. I am still in that phase where I am not familiar with the standard library, so it’s a lot of searching online or perusing through the files. I’ve been trying to study those files to hammer in on the syntax and good ways of doing things
Here is the part that converts the binary into text. I won’t share the other part since the cache is still active. I know that the solution is out there on a puzzle cheat site. It’s also not that difficult to guess who used it, but that’s not a concern of mine.
pub fn binary_to_text<'a>(contents: &'a str) -> String {
let mut result: String = String::new();
for block in contents.split_whitespace() {
let i = u32::from_str_radix(block, 2).expect("Not a binary number!");
result.push(char::from_u32(i).expect("Not Right"));
}
result
}
The other step just uses a match expression. I will have fun tweaking this and refactoring it into better ways of solving the problem. I will also add other text-cipher features as time goes on. I don’t want to use any of the existing crates for that. At least to start, I want to do it myself to use it as a learning exercise.