Rust updates

bearophile bearophileHUGS at lycos.com
Wed Jul 11 13:58:07 PDT 2012


Marco Leise:

> Phobos:
>
>    (boxer.d):
>    assert (box(1) == box(cast(byte)1));
> => assert (box(1) == box(1b));
>
>    (algorithm.d):
>    assert(b == [ cast(ubyte) 0, cast(ubyte)2, cast(ubyte)1, 
> cast(ubyte)6, cast(ubyte)5], text(b));
> => assert(b == [ 0ub, 2ub, 1ub, 6ub, 5ub], text(b));

Here b is an ubyte[] of length 5. I think this works:

assert(b == [0, 2, 1, 6, 5], text(b));

Because this works:

void main() {
     ubyte[] a = [1, 2];
     assert(a == [1, 2]);
}



> => a = 5s;

I read that as "5 seconds" :-(



> GtkD:
>
>    (Color.d and several other occurences):
>    _black = new Color(cast(ubyte)0,cast(ubyte)0,cast(ubyte)0);
> => _black = new Color(0ub,0ub,0ub);

This is a reduction of the Color class of GtkD:

public class Color {
     this(ubyte red, ubyte green, ubyte blue) {}
}

There is no need to use those casts:

void main() {
     auto _black = new Color(0, 0, 0);
}


> ScintillaD:
>
>    (SciTEWin.d):
>    SendMessage(HwndOf(wText), CB_SETEDITSEL, 0, MAKELPARAM(0, 
> cast(ushort)-1));
> => SendMessage(HwndOf(wText), CB_SETEDITSEL, 0, MAKELPARAM(0, 
> -1us));

"cast(ushort)-1" isn't a good idiom in D. Better to write 
"ushort.max".


I don't think your examples justify the increased language 
complexity.

Bye,
bearophile


More information about the Digitalmars-d mailing list