Day 14 — I rewrote itslit in Rust!

Today I read through ownership, references and borrowing in Rust. I can't write about what I learned in this short post as I spent all my time playing skribbl at game night (it was really fun and I would totally do it again!). I also did a lot of rustlings, I love the exercises and I hope they never end!

I set out with a goal of writing a very simple CLI using Rust, to apply all the things I've been learning. And thought that it might be a good idea to rewrite itslit in Rust as it just (1) reads lines from a file into a list of strings, (2) chooses a random string (a talk url) from that list, (3) and opens it in the browser. I came up with this and published it as a crate! This is all of it:

  use rand::seq::SliceRandom;
  use rand::thread_rng;
  use opener::open;

  fn main() {
      let talks: Vec<&str> = include_str!("data/lightning_talks").split("\n").collect();
      let talk = talks.choose(&mut thread_rng()).unwrap();
      opener::open(talk).expect("Could not open link");

I wonder how big the compiled binary would be when the talk urls file becomes really large.