I need to create a Vec like this code :
use serde::{Serialize, Deserialize};
trait TPlugin<'a, Config> where Config : Serialize + Deserialize<'a> {}
#[derive(Serialize, Deserialize)]
struct MyConfig {}
struct MyPlugin1 {
conf: MyConfig,
}
impl TPlugin<MyConfig> for MyPlugin1 {}
impl MyPlugin1 {
pub fn new() -> MyConfig1 {
MyConfig1{}
}
}
fn main() {
let my_vec: Vec<Box<dyn TPlugin<????>>> = Vec::new();
my_vec.push(MyConfig1::new());
my_vec.push(MyConfig2::new());
}
What is the code that I must add instead of "????"? I've tried Box<dyn Serialize + Deserialize<'a>>
but rust tells me "the trait serde::Serialize
cannot be made into an object".
I'm newbie on rust, so generics are obscure for me, like lifetimes. I'm from Java/Typescript. In Java/Typescript I write:
let myVec: Vec<TPlugin<?>>;
Regards.