macro_rules! add_object {
    ($component:expr, $obj_type:ty, $object:expr, [$trait1:ty]) => { ... };
    ($component:expr, $obj_type:ty, $object:expr, [$trait1:ty], [$trait2:ty]) => { ... };
    ($component:expr, $obj_type:ty, $object:expr, [$trait1:ty], [$trait2:ty, $($trait3:ty),+]) => { ... };
    ($component:expr, $obj_type:ty, $object:expr, [$trait1:ty, $($trait2:ty),+]) => { ... };
    ($component:expr, $obj_type:ty, $object:expr, [$trait1:ty, $($trait2:ty),+], [$trait3:ty]) => { ... };
    ($component:expr, $obj_type:ty, $object:expr, [$trait1:ty, $($trait2:ty),+], [$trait3:ty, $($trait4:ty),+]) => { ... };
}
Expand description

Use this to add an object along with its associated traits to a component. Note that repeated traits are listed in a second optional list.

§Examples

#![feature(lazy_cell)]
use gear_objects::*;
use core::fmt;
use paste::paste;
use std::fmt::{Display};

struct Apple {}
register_type!(Apple);

trait Fruit {
    fn eat(&self) -> String;
}
register_type!(Fruit);

impl Fruit for Apple {
    fn eat(&self) -> String {
        "yum!".to_owned()
    }
}

impl fmt::Display for Apple {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "Apple")
    }
}
register_type!(Display);

let apple = Apple {};
let mut component = Component::new("apple");
add_object!(component, Apple, apple, [Fruit], [Display]);