I recently became curious about the different tools that are available to do one specific thing in Rust: provide an implementation of the std::io::Write trait for an in-memory buffer.

This might be useful if you have serializable data that you want to store in a database, or if you want to add checksums or perform compression before storing or sending some data. It may also be useful for buffering ordinary network writes (though BufWriter might be easier).

How can this be done in Rust? What's the most efficient way of buffering serialized data?

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.