I have a vector of functiony enums. I want to clone this vector en masse. However, my Action enum can't derive Clone because Clone isn't implemented for a
fn(&mut Vec<i32>) It works if it's
fn(Vec<i32>) though. It doesn't seem to like fns that borrow their parameters. Why is this? Is there a way for me to do this?
#[derive(Clone)] enum Action { Function (fn(&mut Vec<i32>)) } fn pop(vec:&mut Vec<i32>) { let _ = vec.pop(); } fn main() { let actions = vec![ Action::Function(pop), Action::Function(pop) ]; let actions_copy = actions.to_vec(); }