query_interface
Dynamically query a type-erased object for any trait implementation
Example:
extern crate query_interface;
use ;
use Debug;
;
interfaces!;
In short, this allows you to pass around Object
s and still have access to any of the (object-safe) traits
implemented for the underlying type. The library also provides some useful object-safe equivalents to standard
traits, including ObjectClone
, ObjectPartialEq
, ObjectPartialOrd
, ObjectHash
.
To improve usability, the non-object-safe versions of the traits are implemented directly on the Object
trait
object, allowing you to easily clone Object
s and store them in collections.
You can have your own Object
-like traits to enforce some additional static requirements by using the mopo!
macro:
mopo!;
;
interfaces!;
Now you can use CustomObject
in all the ways you could use Object
.
With the "dynamic" feature, you can at runtime register additional traits to be queryable on a type. This allows you to bypass the normal coherence rules: