Is it possible to qualify the Any type to say that the things you're holding implement specific traits (e.g., PartialEq)? Here's my case:
#[derive(Clone,Debug,PartialEq)]
enum Datum {
Int(i64),
Flt(f64),
List(Rc<MyList>),
Other(Rc<Any>)
}
See below for the motivation for this. Point is, I want to Datum to be able to contain values of whatever type is needed I want to put in, and get it out again; but I also want to constrain the other type to be PartialEq (and maybe other traits as well).
Any ideas? I'm not married to using Any, or enums, or whatever, but the above snippet shows well enough what I want.
Background: This is for a language interpreter whose variables may be of various types. The language is to be implemented as a library crate, to be used by Rust apps; and the intent is that the user of the crate should be able to extend the language's type system. Consequently, the answer isn't to simply extend the enum with the specific type. (The language in question is TCL; and in the standard C implementation of TCL this is a common way of introducing domain-specific types into the language.)