Other than fighting with dust allergies, Rust took some of my time in the past few weeks. I kept it in the to learn list for a long time, and finally thought of looking at it due to a blog post by Armin. I do follow his personal blog, and my previous notions about the language came from his blog posts. But in this blog post on official Sentry site, Armin talked about how they fixed a Python performance issue with Rust (rather than writing in C).

Starting

I started with reading The book, which is also the official rust-lang documentation. One may also want to look at the screencasts at intro_rust(). The videos explained the idea behind ownership, and borrowing in a very simple manner. There is also a github project containing various resources related to Rust. I jumped into the Programming Rust book, which is in Early Release state. This book has great in-depth explanations of various features of the language. But always remember the #rust-beginners channel in IRC, there are people who can help you to understand things.

I try to learn any new thing by practicing. Learning a new programming language is not different. I prefer to write small, but usable code, which in turn can solve one of my issue. This is something I had trouble to keep doing in Rust, as most of the book is about explaining a lot of things in details, but not enough examples of code doing things. The nearest thing I found is Rust by Example. Maybe we can add more examples of code which does something useful for the user, or it is just in my mind.

First working code

One of the missing tool for me is an email address search tool for mutt. There are various scripts to search mail addresses from official LDAP server, or sometimes I used goobook for searching mail addresses from my gmail account. I wanted to have a command, which can find an address from any of my mail mail accounts. I have downloaded the google contacts in a CSV file. I also wrote another Python script using regex to find different mail address from my maildirs. But it was slow to print out from all the thousands of mails I have. So, I just tried to have the same in Rust, it was of course faster. Now I have all the unique mail addresses (a few with names too) in a plain text file.

My search tool just reads the whole file every time, and finds the matches. It prints one address in each line, that way I could just plug it in my mutt configuration.

set query_command="searchemailid %s"

Now if you look at the source code, you will find it is a mixture of copy-paste from various examples + a lot of lets change this, and see what happens next. I also thank Icefoz to help me out over IRC.

To end the post, you can install Rust in Fedora 25 using DNF.