A Better Way to Borrow in Rust: Stack Tokens

127 · Armin Ronacher · Nov. 23, 2022, 8:34 a.m.
Summary
As a Rust programmer you are probably quite familiar with how references work in Rust. If you have a value of type T you can generally get various references to it by using the ampersand (&) operator on it. In the most trivial case &T gives you just that: a reference to T. There are however cases where you can get something else. For instance String implements Deref<Target=&str> which lets you also get a &str from it and that system also can be extended to work with mutable references as wel...