Topics:

Visitors from Vancouver Rust via @JonathanLouie and @WangXiaoying

Repo: https://github.com/vancouver-rs/talks

We were joined by two members of the Vancouver Rust Meetup. Wang Xiaoying is PhD student using Rust in an academic project, ConnectorX, a Python package that enables you to load data from databases into Python in the fastest and most memory efficient way. Jonathan Louie dabbles with many languages like Scala and Idris has some interesting game projects written in Rust like a Wii Play Tanks clone made with Bevy.

Conversation around Steve Klabnik's "I Refuse to Let Amazon Define Rust" Tweet

We talked about Steve Klabnik's tweet responding to an article by Matt Asay which suggested that Rust's principles were modeled after Amazon's leadership principles.

Originally Rust was developed by a single person, Graydon Hoare. It expanded to a team of developers. Now it is community-run and has a foundation. That's a good thing. Do we really want a TC39 committee controlled by FAANG companies to hand things down to us? The point of the Rust foundation should be to cycle in new blood.

We also talked about Rust's async roadmap, specifically about how Generic Associated Types (GATs) are coming soon to Rust.

Rant on (the lack of) Overloading via @NathanBrown

Repo: https://github.com/ngbrown/rust-in-action

Nathan is working through the projects in the Rust in Action book by Tim McNamara. In the Chapter 3 project, he has a File struct containing name and data fields. Sometimes he wants to create a File with only a name (data is empty). Sometimes, he wants to create a File with both name and data. He wishes that he could overload the new() method; that way he wouldn't have to think about the name of the method, just its parameters. However, this is not possible in Rust. The best he could do was have an enum enumerating the possible parameter combinations and use the From to convert the tuples passed in into the appropriate enum type. There is a StackOverflow answer that describes how to do this.

Jacob mentioned the builder pattern as Rust's way of constructing complex data structures. With the builder pattern, you make a struct to hold all the intermediates and then a final build step that checks that you have everything you need before making the final struct. So rather than overloading, we could have something like:

File::new()
  .withData()
  .returnsTheThing()

You can use macros to hide the complexity behind an abstraction. However, macros are a crutch and generally only make problems worse. Blaine ranted about macros before, and in fact that conversation proceeded the same way: builder pattern ➡ macros ➡ Blaine rants about macros.

Language Negotiation via @JesusGuzmanJr

Jesus was working on adding Language Negotiation to his Rocket web server using the unic-langid crate. It has a very straight-forward API and he enjoyed working with it.

Crates You Should Know

  • nokhwa: A Simple-to-use, cross-platform Rust Webcam Capture Library
  • unic-langid: API for managing Unicode Language Identifiers

Rust Apps You Should Know

  • espanso: A full-blown text expander written in Rust