]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/src/test_docs/lib.rs
Auto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se
[rust.git] / src / test / rustdoc-gui / src / test_docs / lib.rs
1 //! The point of this crate is to be able to have enough different "kinds" of
2 //! documentation generated so we can test each different features.
3
4 #![crate_name = "test_docs"]
5 #![feature(doc_keyword)]
6 #![feature(doc_cfg)]
7
8 use std::convert::AsRef;
9 use std::fmt;
10
11 /// Basic function with some code examples:
12 ///
13 /// ```
14 /// println!("nothing fancy");
15 /// ```
16 ///
17 /// A failing to compile one:
18 ///
19 /// ```compile_fail
20 /// println!("where did my argument {} go? :'(");
21 /// ```
22 ///
23 /// An ignored one:
24 ///
25 /// ```ignore (it's a test)
26 /// Let's say I'm just some text will ya?
27 /// ```
28 ///
29 /// An inlined `code`!
30 pub fn foo() {}
31
32 /// Just a normal struct.
33 pub struct Foo;
34
35 impl Foo {
36     #[must_use]
37     pub fn must_use(&self) -> bool {
38         true
39     }
40 }
41
42 impl AsRef<str> for Foo {
43     fn as_ref(&self) -> &str {
44         "hello"
45     }
46 }
47
48 /// Just a normal enum.
49 #[doc(alias = "ThisIsAnAlias")]
50 pub enum WhoLetTheDogOut {
51     /// Woof!
52     Woof,
53     /// Meoooooooow...
54     Meow,
55 }
56
57 /// Who doesn't love to wrap a `format!` call?
58 pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {
59     format!("{:?}", t)
60 }
61
62 /// Woohoo! A trait!
63 pub trait AnotherOne {
64     /// Some func 3.
65     fn func3();
66
67     /// Some func 1.
68     fn func1();
69
70     fn another();
71     fn why_not();
72
73     /// Some func 2.
74     fn func2();
75
76     fn hello();
77 }
78
79 /// ```compile_fail
80 /// whatever
81 /// ```
82 ///
83 /// Check for "i" signs in lists!
84 ///
85 /// 1. elem 1
86 /// 2. test 1
87 ///    ```compile_fail
88 ///    fn foo() {}
89 ///    ```
90 /// 3. elem 3
91 /// 4. ```ignore (it's a test)
92 ///    fn foo() {}
93 ///    ```
94 /// 5. elem 5
95 ///
96 /// Final one:
97 ///
98 /// ```ignore (still a test)
99 /// let x = 12;
100 /// ```
101 pub fn check_list_code_block() {}
102
103 /// a thing with a label
104 #[deprecated(since = "1.0.0", note = "text why this deprecated")]
105 #[doc(cfg(unix))]
106 pub fn replaced_function() {}
107
108 /// Some doc with `code`!
109 pub enum AnEnum {
110     WithVariants { and: usize, sub: usize, variants: usize },
111 }
112
113 #[doc(keyword = "CookieMonster")]
114 /// Some keyword.
115 pub mod keyword {}
116
117 /// Just some type alias.
118 pub type SomeType = u32;
119
120 pub mod huge_amount_of_consts {
121     include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs"));
122 }
123
124 /// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`.
125 pub mod long_code_block {}