]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/deref-recursive.rs
rustdoc: use details tag for trait implementors
[rust.git] / src / test / rustdoc / deref-recursive.rs
1 // #26207: Show all methods reachable via Deref impls, recursing through multiple dereferencing
2 // levels if needed.
3
4 // @has 'foo/struct.Foo.html'
5 // @has '-' '//*[@id="deref-methods-Bar"]' 'Methods from Deref<Target = Bar>'
6 // @has '-' '//*[@class="impl-items"]//*[@id="method.bar"]' 'pub fn bar(&self)'
7 // @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref<Target = Baz>'
8 // @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)'
9 // @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>'
10 // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.bar"]' 'bar'
11 // @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>'
12 // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.baz"]' 'baz'
13
14 #![crate_name = "foo"]
15
16 use std::ops::Deref;
17
18 pub struct Foo(Bar);
19 pub struct Bar(Baz);
20 pub struct Baz;
21
22 impl Deref for Foo {
23     type Target = Bar;
24     fn deref(&self) -> &Bar { &self.0 }
25 }
26
27 impl Deref for Bar {
28     type Target = Baz;
29     fn deref(&self) -> &Baz { &self.0 }
30 }
31
32 impl Bar {
33     /// This appears under `Foo` methods
34     pub fn bar(&self) {}
35 }
36
37 impl Baz {
38     /// This should also appear in `Foo` methods when recursing
39     pub fn baz(&self) {}
40 }