Hacker News new | past | comments | ask | show | jobs | submit
Sure, but behind the scenes, the string is stored in memory as a list of bytes, and the list of bytes gets longer if you lower-case it. Rust pulls a nice curtain in front of all the nasty pointers and registers, but this problem can't be eliminated.
Way to go in completely ignoring the GP's point that Rust does not do that, because Rust does not export that operation you are describing. The only way to get that behavior in Rust is to write the conversion code by hand, with the wrong behavior.
The only way it works so elegantly in Rust is that someone wrote a much nastier implementation behind the scenes. When the Rust end-user gets that nice Iterator, someone behind the scenes has to decode the string and decide how many bytes the new Iterator has. Complexity can be hidden, but it can't be eliminated.
loading story #50561549
loading story #50561668