On Tuesday, 1 August 2017 at 22:52:26 UTC, H. S. Teoh wrote:
On Tue, Aug 01, 2017 at 06:46:17PM -0400, Steven Schveighoffer via Digitalmars-d wrote:
On 8/1/17 6:17 PM, Moritz Maxeiner wrote:
[...]
> import std.algorithm;
> // I probably wouldn't even define this but use the body as > is
> auto strnlen_safe(in char[] str)
> {
>      return countUntil(cast(ubyte[]) str, '\0');
> }

Oh that cast.... it irks me so.
[...]

Welcome to the wonderful world of autodecoding. :-D

OTOH, we could just use byCodeUnit and we wouldn't need the cast, I think.

I was lazy, okay (I nearly forgot putting the auto decoding prevention in there, because I always forget that D has auto decoding; it irks me as well) :p

Reply via email to