How to clone a boxed closure

It will first treat it as the real type: [closure@test4.rs:10:24: 12:6]. This may not seem like a type but it is.

The next two errors are because a trait object may not be sized and can't be on the stack as a result.

The last error is the same as before, there is nothing in the type indicating that what is inside the box implements Clone.

This is a working example with trait object based on my previous link.

4 Likes