Skip to content

Commit b5a783b

Browse files
committed
Merge pull request #2378 from tom-tan/trusted-file-readText
Mark std.file.readText as trusted
2 parents d52190c + 7aecde3 commit b5a783b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

std/file.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ enforce(chomp(readText("deleteme")) == "abc");
346346
----
347347
*/
348348

349-
S readText(S = string)(in char[] name)
349+
S readText(S = string)(in char[] name) @safe if (isSomeString!S)
350350
{
351-
auto result = cast(S) read(name);
351+
static auto trustedCast(void[] buf) @trusted { return cast(S)buf; }
352+
auto result = trustedCast(read(name));
352353
std.utf.validate(result);
353354
return result;
354355
}

0 commit comments

Comments
 (0)