I admit defeat.

A few weeks ago I was writing some Rust code, building basic data structures from scratch, just for practice and curiosity. At one point I wrote what I thought to be a fairly simple and straightforward function, and discovered that there is no way to convince the borrow checker of its correctness.

I spent a lot of time studying the code and a bunch of variations. After many attempts at fixing it, I am giving up: Rust will not allow this function to compile; the borrow checker wins this time.

What does the trait bound 'static mean in Rust?

After a few weeks of programming in Rust we should have a pretty good idea of what a 'static reference is, but a 'static trait bound can seem a bit more mysterious.

The first time I had to add a 'static trait bound to my code. I didn't feel like I understood what was happening, because there were no references involved. In fact, the only data involved were function arguments being passed by ownership, which is usually a pretty reliable way of avoiding borrow checker problems.

In many cases, the rust compiler will suggest a 'static trait bound to address a problem. The compiler is probably right, but let's explore what it really means so we can be confident that we understand the solution.

Updated 10/2021 to use nom 7.0!

This is a demonstration of building a parser in Rust using the nom crate. I recently built a parser for the cddl-cat crate using nom, and I found it a surprisingly pleasant experience, much better than my past experiences with other parser-generators in other languages.

Since I like Rust a lot, and I need an excuse to do more writing about Rust, I thought I'd do another demonstration project. I decided to choose a simple syntax, to keep this a short project. So I'm going to build a parser for JSON.

I've been experimenting with Rust lately, and have just started following Jon Gjengset's videos. In his latest livestream, Jon started a port of the Java ConcurrentHashMap to Rust. I highly recommend them; it's fun to see how someone with a lot of Rust experience approaches problems.

One of the things that grabbed my attention was his use of crossbeam::epoch. It's a library that helps you write certain kinds of lock-free concurrent data structures, using an "epoch counter" that allows you to disconnect objects from your main data structure and they will be freed later-- without using any per-object atomic reference counters or other major GC overhead.