In order for byCodeUnit to be a near drop-in replacement for strings, it would be nice to have them compare directly with strings. This means, I would expect this to work: assert("hello".byCodeUnit == "hello"); This probably means adding opEquals overloads for everything, which also means adding toHash overloads. I'd say just comparing to the base type should be sufficient, no need for transcoding for comparison.
It shouldn't matter the constancy of the original. This should also work: assert("hello".byCodeUnit == "hello".dup.byCodeUnit);
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9763 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB