Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Bar;
- trait Foo {
- fn foo(&self) {
- print!("Foo");
- }
- }
- impl Foo for Bar {}
- trait Print {
- type Kind;
- fn print(&Self::Kind);
- }
- impl Print for Bar {
- type Kind = Bar;
- fn print(_: &Bar) {
- println!("Bar");
- }
- }
- impl Print for Foo {
- type Kind = Bar;
- fn print(bar: &Bar) {
- bar.foo();
- Bar::print(bar);
- }
- }
- fn main() {
- let b = Bar;
- Bar::print(&b); // prints: Bar
- Foo::print(&b); // prints: FooBar
- <Bar as Foo>::print(&b); // error
- }
- <anon>:35:5: 35:25 error: unresolved name `Foo::print`
- <anon>:35 <Bar as Foo>::print(&b);
- ^~~~~~~~~~~~~~~~~~~~
- error: aborting due to previous error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement