Yes, Rust has a `deriving` attribute one can attach to types (for stuff like `Eq`, `Ord`, etc.).
That said, as long as the vtable is already there, I think Rust should do what Haskell is moving to (automatically `derive Typeable`) - that is, automatically place the necessary data in the vtable. Haskell does place a restriction on _using_ the data, though. One must explicitly request the type T has the trait `Typeable` in order to invoke functionality that uses the data. Even though "all types" implement this trait, this explicitly warns the caller that "this function may do strange things". I'm not sure what the right choice would be in Rust here. On Fri, Aug 23, 2013 at 7:44 PM, Danny Gratzer <[email protected]>wrote: > I guess it's worth pointing out GHC's -XDeriveDataTypeable language > extension, this let's the compiler automatically derive the Typeable > instance for user defined datatypes. If you want to copy Data.Typeable > having something (a macro?) to automagically implemented Typeable goes a > long way to aiding usability. > > I'm not sure if an equivalent to Haskell's `derive` exists in Rust. I'm > rather new here :) > > > Cheers, > Danny Gratzer > > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
