Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix array(String) to work with no autodecode #7133

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ Returns:
a `dchar[]`, `const(dchar)[]`, or `immutable(dchar)[]` depending on the constness of
the input.
*/
ElementType!String[] array(String)(scope String str)
CopyTypeQualifiers!(ElementType!String,dchar)[] array(String)(scope String str)
if (isNarrowString!String)
{
import std.utf : toUTF32;
auto temp = str.toUTF32;
/* Unsafe cast. Allowed because toUTF32 makes a new array
and copies all the elements.
*/
return () @trusted { return cast(ElementType!String[]) temp; } ();
return () @trusted { return cast(CopyTypeQualifiers!(ElementType!String, dchar)[]) temp; } ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make one of these auto. That is a horrible return type to spell out twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah I meant typeof(return)

}

///
Expand All @@ -277,7 +277,6 @@ if (isNarrowString!String)
import std.range.primitives : isRandomAccessRange;

assert("Hello D".array == "Hello D"d);
static assert(isRandomAccessRange!string == false);

assert("Hello D"w.array == "Hello D"d);
static assert(isRandomAccessRange!dstring == true);
Expand Down