What puzzled me is that when defining run is normally, but when calling foo.run(), it seems that the lifetime of foo is too short. I haven't figured out why the destructor causes a lifetie error. Thank you for your reply!
dyn Trait<T> is invariant in T, so dyn Fn(&'a T) is invariant in &'a T, so it's invariant in 'a. That means you end up creating a &'a dyn Trait<'a>, effectively borrowing the trait object for the rest of its lifetime. That means it will be impossible to move or destroy it.
You should almost always avoid &'a (mut) T<'a>, and the explicit lifetime parameter in &'a self is the first sign that you are doing something wrong.