The Secret Life of Cows

https://deterministic.space/secret-life-of-cows.html

TIL that you can use Rust’s Cow for representing a type that can either be borrowed or owned. This can be useful when you want to, for example, return either a static string (&'static str) or a dynamically generated owned string (String) from a function.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *