]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/intra-doc/self.rs
Rollup merge of #93755 - ChayimFriedman2:allow-comparing-vecs-with-different-allocato...
[rust.git] / src / test / rustdoc / intra-doc / self.rs
1 #![crate_name = "foo"]
2
3
4 // @has foo/index.html '//a/@href' 'struct.Foo.html#method.new'
5 // @has foo/struct.Foo.html '//a/@href' 'struct.Foo.html#method.new'
6
7 /// Use [`new`] to create a new instance.
8 ///
9 /// [`new`]: Self::new
10 pub struct Foo;
11
12 impl Foo {
13     pub fn new() -> Self {
14         unimplemented!()
15     }
16 }
17
18 // @has foo/index.html '//a/@href' 'struct.Bar.html#method.new2'
19 // @has foo/struct.Bar.html '//a/@href' 'struct.Bar.html#method.new2'
20
21 /// Use [`new2`] to create a new instance.
22 ///
23 /// [`new2`]: Self::new2
24 pub struct Bar;
25
26 impl Bar {
27     pub fn new2() -> Self {
28         unimplemented!()
29     }
30 }
31
32 pub struct MyStruct {
33     // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#structfield.struct_field'
34
35     /// [`struct_field`]
36     ///
37     /// [`struct_field`]: Self::struct_field
38     pub struct_field: u8,
39 }
40
41 pub enum MyEnum {
42     // @has foo/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.EnumVariant'
43
44     /// [`EnumVariant`]
45     ///
46     /// [`EnumVariant`]: Self::EnumVariant
47     EnumVariant,
48 }
49
50 pub union MyUnion {
51     // @has foo/union.MyUnion.html '//a/@href' 'union.MyUnion.html#structfield.union_field'
52
53     /// [`union_field`]
54     ///
55     /// [`union_field`]: Self::union_field
56     pub union_field: f32,
57 }
58
59 pub trait MyTrait {
60     // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedtype.AssoType'
61
62     /// [`AssoType`]
63     ///
64     /// [`AssoType`]: Self::AssoType
65     type AssoType;
66
67     // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedconstant.ASSO_CONST'
68
69     /// [`ASSO_CONST`]
70     ///
71     /// [`ASSO_CONST`]: Self::ASSO_CONST
72     const ASSO_CONST: i32 = 1;
73
74     // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#method.asso_fn'
75
76     /// [`asso_fn`]
77     ///
78     /// [`asso_fn`]: Self::asso_fn
79     fn asso_fn() {}
80 }
81
82 impl MyStruct {
83     // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.for_impl'
84
85     /// [`for_impl`]
86     ///
87     /// [`for_impl`]: Self::for_impl
88     pub fn for_impl() {
89         unimplemented!()
90     }
91 }
92
93 impl MyTrait for MyStruct {
94     // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType'
95
96     /// [`AssoType`]
97     ///
98     /// [`AssoType`]: Self::AssoType
99     type AssoType = u32;
100
101     // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST'
102
103     /// [`ASSO_CONST`]
104     ///
105     /// [`ASSO_CONST`]: Self::ASSO_CONST
106     const ASSO_CONST: i32 = 10;
107
108     // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.asso_fn'
109
110     /// [`asso_fn`]
111     ///
112     /// [`asso_fn`]: Self::asso_fn
113     fn asso_fn() {
114         unimplemented!()
115     }
116 }