Get the latest tech news
An Optimization That's Impossible in Rust
In this article, I'll describe how I implemented German string and the challenges of doing so in Rust. Specifically, I'll examine how to enable shared ownership for such data structure. Providing unique ownership is relatively trivial, and there is already a nicely written tutorial from the Rustonomicon teaching you how to [implement a `Vec`], which is not much different from a `String`. But first, let's talk about the concept of German string.
by xkcd licensed under CC BY-NC 2.5 In this article, I’ll describe how I implemented German string and the challenges of doing so in Rust. Providing unique ownership is relatively trivial, and there is already a nicely written tutorial from the Rustonomicon teaching you how to implement a Vec<T>, which is not much different from a String. A better approach is as follows, without relying on such an invariant and freeing us from worrying about field orders when providing structs for different ownership strategies for the allocated buffer.
Or read this on Hacker News