News for hackers. Stuff that matters.
Re:String types in Rust by steveklabnik on Monday March 28, 2016 @05:04PM (#11377390)
Cow in general is on my shortlist for "I need to improve the docs."

One area where it's used effectively in the stdlib is String::from_utf8_lossy: http://doc.rust-lang.org/collections/string/struct.String.ht...

If the argument is valid UTF-8, then no allocations need to be performed, and so the returned value will be a &str. But if it's not valid UTF-8, the replacement characters need to be inserted, which means allocation, which means String will be returned.

There are no comments on this comment yet.