I have a simple program where I am trying to implement a polymorphic account type:
enum AccountType { INVALID, TYPE1, TYPE2, } trait Account {
The compiler's suggestion actually works. If you write add_account as follows:
add_account
fn add_account(&mut self, account: A) { self.accounts.push(Box::new(account)); }
your code compiles. (Incidentally, you need &mut self, not &self here)
&mut self
&self