Naming things is a notorious task as a developer and it’s a constant struggle. I often have two or more browser tabs open in order to find the words I’m looking for. And then one day it hit me.

Wouldn’t it be nice to have a synonym searcher in the terminal?.

With no time to waste, all other side-projects were abandoned in an instant and my path to a better named world began.

Photo by Tolga Ulkan on Unsplash

Goal 🥅


I’ve been looking at web-scraping for a side project of mine and thought I’d have a look at what Rust has to offer. I found the select crate, which seemed to have all right stuff.

Now I just needed some website for target practice 🎯.
I was reading an article on the Associated Press’s website at the moment so…
The news it is!

With tools and target set, let’s try digging out some information from the data soup called HTML 🍲.

Photo by Luís Feliciano on Unsplash

The Select crate 📦


Photo by Tandem X Visuals on Unsplash

I was reading about the PhantomData type and came across the point made that it can be used as a mechanism for controlling lifetimes. From here I started to play around with it a bit and came up with something interesting.

The example itself might be a bit awkward, but bare with me :)

The Scenario 🗺️

When the Reader is…


I was browsing through the Rust standard library and came across PhantomData. I didn’t know what it was used for, so I started reading more about it.

Rust won’t allow you to declare a type parameter without using it. The solution is PhantomData. The PhantomData type can be used in situations when you really don’t need to store the value of something but rather, just the type. There are some examples in Rust’s documentation, but I thought I’d try one out for myself.

Photo by Nicolas Lobos on Unsplash

The Final Frontier 👩‍🚀


Photo by Szűcs László on Unsplash

From one to the other

The problem

The code


A few nights ago I stumbled upon this thread on reddit, discussing database migrations.Part of the discussion focused around a zero-downtime strategy.

The strategy of always adding and never changing an existing column came up. I later ended up reading this blog and watched this talk.

After this I really just wanted to do this myself — so a few hours later and I had a toy example.

I’ll write about the example I’ve created and won’t focus too much on the nitty gritty details in each blog/video. Follow the links if you want more :)

Before we start

Pre-requisites for following along…


Photo by Paweł Czerwiński on Unsplash

A fixed-size array, denoted [T; N], for the element type, T, and the non-negative compile-time constant size, N.

This is what you find when you read the first few lines of the documentation about the array type in Rust.

Let’s go through this piece by piece.
To begin with we have the following

A fixed-size array …

Alright, so now we know that the array will never grow or shrink in memory. If you create an array with the capacity to hold 5 elements of the type bool it will forever be an array that can hold 5 bools.

We…

robert barlin

… a little bit of everything :)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store