APRIL 16, 2016
Some of the first Rust code I wrote was a struct with a
&str field. As you
might imagine, the borrow checker didn’t let me do a lot of things, and the API
ergonomics were limited. This article aims to demonstrate the issues with having
&str references in structs, introduce some intermediate APIs that
alleviate the ergonomics but aren’t necessarily efficient, and end with an
implementation that is both ergonomic and efficient.