]>
Commit | Line | Data |
---|---|---|
dfeec247 XL |
1 | // Test that the contents of constants are displayed as part of the |
2 | // documentation. | |
3 | ||
4 | // @has show_const_contents/constant.CONST_S.html 'show this' | |
5 | // @!has show_const_contents/constant.CONST_S.html '; //' | |
6 | pub const CONST_S: &'static str = "show this"; | |
7 | ||
8 | // @has show_const_contents/constant.CONST_I32.html '= 42;' | |
9 | // @!has show_const_contents/constant.CONST_I32.html '; //' | |
10 | pub const CONST_I32: i32 = 42; | |
11 | ||
12 | // @has show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' | |
13 | // @!has show_const_contents/constant.CONST_I32_HEX.html '; //' | |
14 | pub const CONST_I32_HEX: i32 = 0x42; | |
15 | ||
16 | // @has show_const_contents/constant.CONST_NEG_I32.html '= -42;' | |
17 | // @!has show_const_contents/constant.CONST_NEG_I32.html '; //' | |
18 | pub const CONST_NEG_I32: i32 = -42; | |
19 | ||
20 | // @has show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' | |
21 | // @!has show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' | |
22 | pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; | |
23 | ||
24 | // @has show_const_contents/constant.CONST_CALC_I32.html '= 42 + 1; // 43i32' | |
25 | pub const CONST_CALC_I32: i32 = 42 + 1; | |
26 | ||
27 | // @!has show_const_contents/constant.CONST_REF_I32.html '= &42;' | |
28 | // @!has show_const_contents/constant.CONST_REF_I32.html '; //' | |
29 | pub const CONST_REF_I32: &'static i32 = &42; | |
30 | ||
f035d41b XL |
31 | // @has show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' |
32 | pub const CONST_I32_MAX: i32 = i32::MAX; | |
dfeec247 XL |
33 | |
34 | // @!has show_const_contents/constant.UNIT.html '= ();' | |
35 | // @!has show_const_contents/constant.UNIT.html '; //' | |
36 | pub const UNIT: () = (); | |
37 | ||
38 | pub struct MyType(i32); | |
39 | ||
40 | // @!has show_const_contents/constant.MY_TYPE.html '= MyType(42);' | |
41 | // @!has show_const_contents/constant.MY_TYPE.html '; //' | |
42 | pub const MY_TYPE: MyType = MyType(42); | |
43 | ||
44 | pub struct MyTypeWithStr(&'static str); | |
45 | ||
46 | // @!has show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' | |
47 | // @!has show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' | |
48 | pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); | |
49 | ||
74b04a01 XL |
50 | // @has show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288f32;' |
51 | // @has show_const_contents/constant.PI.html '; // 3.14159274f32' | |
52 | pub use std::f32::consts::PI; | |
dfeec247 | 53 | |
f9f354fc | 54 | // @has show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' |
fc512014 | 55 | #[allow(deprecated, deprecated_in_future)] |
dfeec247 XL |
56 | pub use std::i32::MAX; |
57 | ||
58 | macro_rules! int_module { | |
59 | ($T:ident) => ( | |
f035d41b | 60 | pub const MIN: $T = $T::MIN; |
dfeec247 XL |
61 | ) |
62 | } | |
63 | ||
f035d41b | 64 | // @has show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' |
dfeec247 XL |
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>"#; |