Issue 19264 - byCodeUnit should compare with strings
Summary: byCodeUnit should compare with strings
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Mac OS X
: P4 enhancement
Assignee: dcuan17
URL:
Keywords: bootcamp
Depends on:
Blocks:
 
Reported: 2018-09-25 15:55 UTC by Steven Schveighoffer
Modified: 2024-12-01 16:34 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2018-09-25 15:55:38 UTC
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.
Comment 1 Steven Schveighoffer 2018-09-25 15:58:05 UTC
It shouldn't matter the constancy of the original.

This should also work:

assert("hello".byCodeUnit == "hello".dup.byCodeUnit);
Comment 2 dlangBugzillaToGithub 2024-12-01 16:34:14 UTC
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