]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/show-const-contents.rs
Auto merge of #107768 - matthiaskrgr:rollup-9u4cal4, r=matthiaskrgr
[rust.git] / tests / rustdoc / show-const-contents.rs
1 // Test that the contents of constants are displayed as part of the
2 // documentation.
3
4 // @hasraw show_const_contents/constant.CONST_S.html 'show this'
5 // @!hasraw show_const_contents/constant.CONST_S.html '; //'
6 pub const CONST_S: &'static str = "show this";
7
8 // @hasraw show_const_contents/constant.CONST_I32.html '= 42;'
9 // @!hasraw show_const_contents/constant.CONST_I32.html '; //'
10 pub const CONST_I32: i32 = 42;
11
12 // @hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;'
13 // @!hasraw show_const_contents/constant.CONST_I32_HEX.html '; //'
14 pub const CONST_I32_HEX: i32 = 0x42;
15
16 // @hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;'
17 // @!hasraw show_const_contents/constant.CONST_NEG_I32.html '; //'
18 pub const CONST_NEG_I32: i32 = -42;
19
20 // @hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;'
21 // @!hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32'
22 pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32;
23
24 // @hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32'
25 pub const CONST_CALC_I32: i32 = 42 + 1;
26
27 // @!hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;'
28 // @!hasraw show_const_contents/constant.CONST_REF_I32.html '; //'
29 pub const CONST_REF_I32: &'static i32 = &42;
30
31 // @hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32'
32 pub const CONST_I32_MAX: i32 = i32::MAX;
33
34 // @!hasraw show_const_contents/constant.UNIT.html '= ();'
35 // @!hasraw show_const_contents/constant.UNIT.html '; //'
36 pub const UNIT: () = ();
37
38 pub struct MyType(i32);
39
40 // @!hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);'
41 // @!hasraw show_const_contents/constant.MY_TYPE.html '; //'
42 pub const MY_TYPE: MyType = MyType(42);
43
44 pub struct MyTypeWithStr(&'static str);
45
46 // @!hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");'
47 // @!hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //'
48 pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this");
49
50 // @hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288f32;'
51 // @hasraw show_const_contents/constant.PI.html '; // 3.14159274f32'
52 pub use std::f32::consts::PI;
53
54 // @hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32'
55 #[allow(deprecated, deprecated_in_future)]
56 pub use std::i32::MAX;
57
58 macro_rules! int_module {
59     ($T:ident) => (
60         pub const MIN: $T = $T::MIN;
61     )
62 }
63
64 // @hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16'
65 int_module!(i16);
66
67 // @has show_const_contents/constant.ESCAPE.html //pre '= r#"<script>alert("ESCAPE");</script>"#;'
68 pub const ESCAPE: &str = r#"<script>alert("ESCAPE");</script>"#;