about summary refs log tree commit diff
path: root/tests/rustdoc/deref/deref-methods-24686-target.rs
blob: e019488ca802373e54a55ad9b9ec323217bd9ee8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#![crate_name = "foo"]

// test for https://github.com/rust-lang/rust/issues/24686
use std::ops::Deref;

pub struct Foo<T>(T);
impl Foo<i32> {
    pub fn get_i32(&self) -> i32 { self.0 }
}
impl Foo<u32> {
    pub fn get_u32(&self) -> u32 { self.0 }
}

// Note that the same href is used both on the method itself,
// and on the sidebar items.
//@ has foo/struct.Bar.html
//@ has - '//a[@href="#method.get_i32"]' 'get_i32'
//@ !has - '//a[@href="#method.get_u32"]' 'get_u32'
//@ count - '//ul[@class="block deref-methods"]//a' 1
//@ count - '//a[@href="#method.get_i32"]' 2
pub struct Bar(Foo<i32>);
impl Deref for Bar {
    type Target = Foo<i32>;
    fn deref(&self) -> &Foo<i32> {
        &self.0
    }
}