Rant after trying Rust a bit

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 27 00:21:36 PDT 2015


Walter Bright <newshound2 at digitalmars.com> wrote:
> On 7/26/2015 3:44 PM, deadalnix wrote:
>> or template code (which will blow up at instanciation time, or worse, do random
>> shit).
> 
> Um, all Rust traits do is test for a method signature match, so it
> compiles. It is NOT a defense against a random method that just happens
> to match and does some other unrelated random shit.

Rust traits have to be implemented *explicitly*. It's not just an implicit
test for a matching signature.

> For example, the '+' operator. Rust traits sez "gee, there's a +
> operator, it's good to go. Ship it!" Meanwhile, you thought the function
> was summing some data, when it actually is creating a giant string, or
> whatever idiot thing someone decided to use '+' for.

+ operator is somewhat special because it can only be implemented via
trait. That doesn't apply for normal methods.

> Rust still has not obviated the necessity for unit tests, nor is Rust
> remotely able to guarantee your code doesn't "do random shit" if it compiles.

An example:
Rust std lib defines two traits, PartialOrd and Ord. Ord depends on
PartialOrd but doesn't provide any new methods.
And it's clearly documented when to implement Ord and when PartialOrd.
So sure, someone could decide to deliberately ignore that, but then I just
don't care anymore.

Tobi


More information about the Digitalmars-d mailing list