[rust-dev] Deriving keyword
dbau.pp at gmail.com
Thu Jan 23 20:38:58 PST 2014
On 24/01/14 15:32, benjamin adamson wrote:
> Question, what constitutes whether a 'trait' is applicable for
> implementation by the #deriving() attribute?
> According to the language specification on master:
> There exists a static list. I found myself interested in the idea of
> using the deriving attribute to derive a simple drawable implementation:
> but then looked up the attribute in the rust manual, and noticed that
> there is a static list of what I will call 'traits that support the
> deriving attribute'. Why the restriction? Is there some prior reading
> on this? Is there any plan on letting libraries define more types that
> can be 'derivable'?
> Rust-dev mailing list
> Rust-dev at mozilla.org
There's a static list because they're currently hard-coded into the
With external syntax extensions, it's now possible to define something
like `#[deriving_Drawable]`, and, iirc, I left the core deriving
infrastructure public in syntax::ext::deriving::generic, so you can get
most of the work done for you that way.
There are various things to be worked out for adding traits directly to
#[deriving(Foo)], including (but not limited to) how namespacing works
(e.g. if two libraries both define a trait with the same name and
provide #[deriving] implementations for it), and whether we want it to
be a priviledged syntax extension where users can directly add to its
map between traits and deriving implementation.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rust-dev