#![feature(arbitrary_self_types)]
struct Foo<T>(T);
struct Bar;
impl std::ops::Deref for Foo<u32> {
type Target = Bar;
fn deref(&self) -> &Self::Target {
&Bar
}
}
impl Foo<i32> {
fn call_me(self) {
println!("Foo");
}
fn call_me_receiver(&self) {
println!("Foo");
}
}
impl Bar {
fn call_me(self) {
println!("Bar");
}
fn call_me_receiver(self: Foo<u32>) {
println!("Bar");
}
}
fn main() {
let x = Foo(Default::default());
x.call_me(); // Foo
let x = Foo(Default::default());
x.call_me_receiver(); // Bar
}