How to coerce a Vec of structs to a Vec of trait objects?
问题 Trying to create a DB struct that is a HashMap of vectors. Each Vec contains Box<dyn Model> . use std::collections::HashMap; trait Model { fn id(&self) -> i32; } struct User; struct Message; impl Model for User { fn id(&self) -> i32 { 4 } } impl Model for Message { fn id(&self) -> i32 { 3 } } struct DB { users: Vec<Box<User>>, messages: Vec<Box<Message>>, tables: HashMap<String, Vec<Box<dyn Model>>>, } impl DB { fn new() -> Self { let users: Vec<Box<User>> = Vec::new(); let messages: Vec<Box