A D vs. Rust example

Dukc ajieskola at gmail.com
Mon Oct 31 21:54:21 UTC 2022


On Sunday, 30 October 2022 at 02:29:36 UTC, Walter Bright wrote:

>
> 3. detecting bad UTF-8 encodings only happens when decoding is 
> needed. It costs nothing extra, as it falls out of the decoding 
> logic. Then, one can decide to safely ignore it, or use the 
> Replacement Char.

If the algorithm does not throw on invalid UTF, I guess so.

>
> It works fine. There just is no need to purify the strings.

No need, but a bit of benefit since some bugs could be catched at 
compile time.

Then again, it'd be catching only one class of errors of the 
countess one that are possible. Rust's solution would still be of 
no help if we're excepting letters but receive numbers instead 
and forget to check. So maybe complexity-to-benefit ratio of it 
is still unfavourable. Someone with experience with Rust string 
handling could maybe judge it.


More information about the Digitalmars-d mailing list