blob: f0214dc636138a3041139d528d58572b2aa7667e [file] [log] [blame]
//! Trait objects only allow access to methods defined in the trait.
trait MyTrait {
fn trait_method(&mut self);
}
struct ImplType;
impl MyTrait for ImplType {
fn trait_method(&mut self) {}
}
impl ImplType {
fn struct_impl_method(&mut self) {}
}
fn main() {
let obj: Box<dyn MyTrait> = Box::new(ImplType);
obj.struct_impl_method(); //~ ERROR no method named `struct_impl_method` found
}