Daily Shaarli

All links of one day in a single page.

February 9, 2024

Design safe collection API with compile-time reference stability in Rust - COCl2's blog home

This article explores how we can separate the lifetime of values in a container from the lifetime of the container structure. The author approach the problem by issuing a token (zero-sized type) with an invariant lifetime. TIL ghost token. I think the type AppendOnlyVec (Vec<Box<T>>) could make a more straightforward example.