Closed
Description
This will compile:
use std::sync::Arc;
trait TestTrait {}
pub struct Shared {
pub thing: Arc<Box<TestTrait + Send + Share>>
}
impl Clone for Shared {
fn clone(&self) -> Shared {
Shared {
thing: self.thing.clone()
}
}
}
But adding a :Clone
bound to the TestTrait
definition like so:
use std::sync::Arc;
trait TestTrait: Clone {}
pub struct Shared {
pub thing: Arc<Box<TestTrait + Send + Share>>
}
impl Clone for Shared {
fn clone(&self) -> Shared {
Shared {
thing: self.thing.clone()
}
}
}
Fails with:
src/shared.rs:12:20: 12:38 error: cannot call a method whose type contains a self-type through an object
src/shared.rs:12 thing: self.thing.clone()
^~~~~~~~~~~~~~~~~~
I think this is just a name resolution issue, but I'm not sure why this happens.
Metadata
Metadata
Assignees
Labels
No labels