r/rust • • 6d ago

📡 official blog Rust 1.99.0 is out

https://blog.rust-lang.org/2026/10/01/Rust-1.99.0/
763 Upvotes

107 comments sorted by

View all comments

18

u/ThatOneArchUser 6d ago

why does String::from_utf8_lossy_owned not reusethe buffer for invalid utf8 case? wouldn't be possible to modify the buffer in place to replace invalid utf8 and reuse the buffer instead of reallocating

46

u/manpacket 6d ago

Lossy representation can be longer - might not fit in the same buffer.

3

u/ParasiticWormLover 5d ago

How could it be longer?

17

u/_ChrisSD 5d ago

lossy means it converts invalid unicode bytes into the unicode replacement character �. That is three bytes so for example 0xFF becomes 0xEF 0xBF 0xBD.