Skip to content

Commit 047a70f

Browse files
committed
rustdoc: add test for "Methods from Deref"
1 parent 57e88ab commit 047a70f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![crate_name = "foo"]
2+
3+
// test for https://github.com/rust-lang/rust/issues/24686
4+
use std::ops::Deref;
5+
6+
pub struct Foo<T>(T);
7+
impl Foo<i32> {
8+
pub fn get_i32(&self) -> i32 { self.0 }
9+
}
10+
impl Foo<u32> {
11+
pub fn get_u32(&self) -> u32 { self.0 }
12+
}
13+
14+
// Note that the same href is used both on the method itself,
15+
// and on the sidebar items.
16+
//@ has foo/struct.Bar.html
17+
//@ has - '//a[@href="#method.get_i32"]' 'get_i32'
18+
//@ !has - '//a[@href="#method.get_u32"]' 'get_u32'
19+
//@ count - '//ul[@class="block deref-methods"]//a' 1
20+
//@ count - '//a[@href="#method.get_i32"]' 2
21+
pub struct Bar(Foo<i32>);
22+
impl Deref for Bar {
23+
type Target = Foo<i32>;
24+
fn deref(&self) -> &Foo<i32> {
25+
&self.0
26+
}
27+
}

0 commit comments

Comments
 (0)