3 ms·
impl Material for Lambertain { ... fn box_clone(&self) -> Box<Material> { Box::new(Lambertian { ..self }) }
by SCdF 9y ago
impl Material for Lambertain {
...
fn box_clone(&self) -> Box<Material> {
Box::new(Lambertian {
..self
})
}
}
Holllllly shit I think that works.
Why am I allowed to do this and not just derive Clone and Copy!?!
- physguy1123 9y agoCopy and clone have specific meanings and must resolve to the type of the class itself - basically copy or cloning a class of type A gets you another class of type A always. It's possible, from a language sense, to have an implementation of box that could directly clone the trait, but I don't believe it would have a reasonable api.