change Str func

This commit is contained in:
Matthew 2026-02-02 05:54:10 +11:00
parent 988270db0b
commit 53dbb8bf34
2 changed files with 4 additions and 4 deletions

View File

@ -475,7 +475,7 @@ ExecLocation(T)()
} }
auto auto
Cwd(T)() Cwd(T = string)()
{ {
static char[512] buf; static char[512] buf;
@ -487,7 +487,7 @@ Cwd(T)()
} }
else static if(is(T: string)) else static if(is(T: string))
{ {
return ConvToStr(buf)[0 .. strlen(buf.ptr)]; return ConvToStr(buf[0 .. strlen(buf.ptr)]);
} }
} }

4
util.d
View File

@ -14,7 +14,7 @@ import std.traits;
import core.stdc.string : memset; import core.stdc.string : memset;
import core.simd; import core.simd;
enum bool StringType(T) = (is(T: string) || is(T: u8[]) || is(T: char[])); enum bool StringType(T) = (is(T: string) || is(T: u8[]) || is(T: char[]) || is(T: const(char)[]));
pragma(inline) void pragma(inline) void
Int3() Int3()
@ -45,7 +45,7 @@ Assert(T)(T cond, string msg)
} }
string string
Str(T)(T[] arr) Str(T)(T arr) if(StringType!(T))
{ {
return (cast(immutable(char)*)arr.ptr)[0 .. arr.length]; return (cast(immutable(char)*)arr.ptr)[0 .. arr.length];
} }