I am ending up with an error message "type list:Item<'_>
cannot be dereferenced" when I try to clone the trait object Item
via the vector Vec<Item>
iterator next()
method. The iterator next()
returns Option<&Item>
in the while loop, that unwraps to provide just &Item
.
I believe the solution to dereference the reference to Item
would make use of the Deref
trait, after doing plenty searches yet was unable to find an example of dereferencing a reference to a trait object, in order for me to clone the vector element.
I do really want to clone the entire trait object element of the vector to another trait object, that will contain the memory copy of the vector element. Thus there will be two copies of the trait object in memory, yet located in two different structs.