Closed
Description
STR
use std::ops::Deref;
pub struct Foo(Bar);
pub struct Bar(Baz);
pub struct Baz;
impl Deref for Foo {
type Target = Bar;
fn deref(&self) -> &Bar { &self.0 }
}
impl Deref for Bar {
type Target = Baz;
fn deref(&self) -> &Baz { &self.0 }
}
impl Bar {
/// This appears under `Foo` methods
pub fn shows_up(&self) {}
}
impl Baz {
/// But this doesn't, because it requires `deref`ing `Foo` twice
pub fn doesnt_show_up(&self) {}
}
fn test(foo: Foo) {
// Even though both methods are accessible via `Foo`
foo.shows_up();
foo.doesnt_show_up();
}
fn main() {}
Version
rustc 1.2.0-nightly (613e57b44 2015-06-01) (built 2015-06-02)