I have the following trait definition representing a sub-block within a DSL:
pub trait SubBlock {
fn get_command(&self) -> Command;
fn get_parent_id(&self) -> u32;
}
Here
.map(|bsb| {
*bsb
})
you trigger a Copy
not a Clone
.
To be able to .clone()
values, you need to know, that they implement the Clone
trait.
So make it
pub children: Option<Vec<Box<dyn SubBlock + Clone>>>
and implement Clone
for all the things, that might end up in that vector and then use .clone()
.
The rest should become easier after that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.