summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc/intra-doc/self.rs
blob: 0ba7df8a78ad75a57016a09e88f1c676a9f615c9 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#![crate_name = "foo"]


// @has foo/index.html '//a/@href' 'struct.Foo.html#method.new'
// @has foo/struct.Foo.html '//a/@href' 'struct.Foo.html#method.new'

/// Use [`new`] to create a new instance.
///
/// [`new`]: Self::new
pub struct Foo;

impl Foo {
    pub fn new() -> Self {
        unimplemented!()
    }
}

// @has foo/index.html '//a/@href' 'struct.Bar.html#method.new2'
// @has foo/struct.Bar.html '//a/@href' 'struct.Bar.html#method.new2'

/// Use [`new2`] to create a new instance.
///
/// [`new2`]: Self::new2
pub struct Bar;

impl Bar {
    pub fn new2() -> Self {
        unimplemented!()
    }
}

pub struct MyStruct {
    // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#structfield.struct_field'

    /// [`struct_field`]
    ///
    /// [`struct_field`]: Self::struct_field
    pub struct_field: u8,
}

pub enum MyEnum {
    // @has foo/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.EnumVariant'

    /// [`EnumVariant`]
    ///
    /// [`EnumVariant`]: Self::EnumVariant
    EnumVariant,
}

pub union MyUnion {
    // @has foo/union.MyUnion.html '//a/@href' 'union.MyUnion.html#structfield.union_field'

    /// [`union_field`]
    ///
    /// [`union_field`]: Self::union_field
    pub union_field: f32,
}

pub trait MyTrait {
    // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedtype.AssoType'

    /// [`AssoType`]
    ///
    /// [`AssoType`]: Self::AssoType
    type AssoType;

    // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedconstant.ASSO_CONST'

    /// [`ASSO_CONST`]
    ///
    /// [`ASSO_CONST`]: Self::ASSO_CONST
    const ASSO_CONST: i32 = 1;

    // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#method.asso_fn'

    /// [`asso_fn`]
    ///
    /// [`asso_fn`]: Self::asso_fn
    fn asso_fn() {}
}

impl MyStruct {
    // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.for_impl'

    /// [`for_impl`]
    ///
    /// [`for_impl`]: Self::for_impl
    pub fn for_impl() {
        unimplemented!()
    }
}

impl MyTrait for MyStruct {
    // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType'

    /// [`AssoType`]
    ///
    /// [`AssoType`]: Self::AssoType
    type AssoType = u32;

    // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST'

    /// [`ASSO_CONST`]
    ///
    /// [`ASSO_CONST`]: Self::ASSO_CONST
    const ASSO_CONST: i32 = 10;

    // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.asso_fn'

    /// [`asso_fn`]
    ///
    /// [`asso_fn`]: Self::asso_fn
    fn asso_fn() {
        unimplemented!()
    }
}