Re:Trust in Firefox and Mozilla Is Gone – Let's Talk Alterna...
by jpc0 on Monday March 03, 2025 @06:37AM
(#43240753)
It's not about me parsing or creating a str. It's about the 100 dependencies every rust project has which might hand me a str that wasn't parsed safely.
I can avoid UB in my own C++ code too, the fact that the language has UB is a reason I even look at other options from time to time. To find UB in such a fundamental part of safe Rust was truly a surpise to me.
It feels like they could have very easily just made it a byte slice and said it's up yo you to validate, instead they decided it has to be valid UTF-8 or it's UB.
Any way I know of for making a str from bytes is checked or unsafe, even slices (by byte indexes) are checked (panic). Is there a current example that hasn't been fixed at the language level where this invariant can be broken without unsafe?