Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct A;
- struct B;
- struct D;
- trait Trait<Type1> {
- fn method(&self);
- }
- impl Trait<A> for D {
- fn method(&self) {
- println!("{}", "Test");
- }
- }
- impl Trait<B> for D {
- fn method(&self) {
- println!("{}", "Not a test");
- }
- }
- fn main() {
- let v = D{};
- (&v as &dyn Trait<A>).method();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement