notes on rust and other subjects

git_cache_http_server.into_rust(): parsing args

08 June 2021. Estimated reading time: 5 min.

I decided to start rewriting the git cache server in Rust by the command-line interface.

The Haxe implementation used docopt. Originally developed for Python by Vladimir Keleshev, docopt is a command-line argument parsing library where the parser is automatically constructed from the usage message.

I could just use docopt for Rust and be done with it. But what else is there in Rust? And what are my requirements?

Continue reading...

git_cache_http_server.into_rust(): preamble

17 July 2020. Estimated reading time: 3 min.

I originally wrote the git-cache-http-server in 2015, as a proof of concept to ensure the viability of a CI system my company was about to pitch. The system would require cloning fairly large repositories very frequently, and the use of a simple shared local directory was undesirable.

Continue reading...

as, to and into methods in rust

15 July 2020. Estimated reading time: 3 min.

Rust standard library types frequently have methods with names that look like as_something, to_something, or into_something. Clearly the difference between "as", "to" and "into" is intentional, and I realized I didn't know why.

So let's pick String, and take a closer look at the as/to/into methods that are available.

Continue reading...

about these notes

14 July 2020. Estimated reading time: 1 min.

As I type these words, I am learning about Rust, and this is a place to write down interesting things I discover along the way.

But one invariant of reality is that the future is unpredictable, and this description is bound to become inaccurate...

when rust lifetimes finally click

11 July 2020. Estimated reading time: 2 min.

I started learning Rust by reading the Book, cover to cover. Lifetimes were far from the hardest topic for me to get used to, and I even took care to make a mental note that

Lifetime annotations don’t change how long any of the references live.

So I was very surprised to realize that, a few days later, I had no idea what my custom error types were supposed to return when implementing Error::source.

Continue reading...