[rust-dev] A couple of tweaks to make typeclasses easier?

Niko Matsakis niko at alum.mit.edu
Thu Jan 26 20:27:36 PST 2012

On 1/26/12 6:10 PM, Graydon Hoare wrote:
> Depends what it means! Does it pull in the same stuff that "import 
> foo::*" pulls in, in addition to impls? Or just impls? IWO, do I have 
> to double the number of boilerplate lines to get access to 
> foo-and-its-methods?

One thing: I think a lot of the uses of record type + impl in our code 
base might be better phrased as classes.  This would obviate the need to 
pull in an implementation for type "foo" most of the time.  It does 
strike me as somewhat non-obvious where methods are coming from today, 
particularly when "foo::*" is used.

> What was the error message? I'm not trying to be a pain, just 
> concerned that a proliferation of -> symbols through much of our code 
> will read poorly, and want to try to avoid.

The error message in question says something like "no method 
implementation found", even in cases where there is clearly no method 
call.  It ought to be changed, probably to something like "no field or 
method found".

As for "." vs "->", I don't have a very strong opinion.  I somewhat like 
that fields and methods would be in disjoint namespaces, but I can also 
see a counter argument that "->" is not as pretty.


More information about the Rust-dev mailing list