Skip to content

Commit 55e37f9

Browse files
committed
Add examples to int macros
1 parent 8bef0a3 commit 55e37f9

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/libcore/num/int_macros.rs

+24-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,36 @@ macro_rules! int_module {
1212
($T:ident, #[$attr:meta]) => (
1313
doc_comment! {
1414
concat!("The smallest value that can be represented by this integer type.
15-
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."),
15+
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead.
16+
17+
# Examples
18+
19+
```rust
20+
// deprecated way
21+
let min = std::", stringify!($T), "::MIN;
22+
23+
// intended way
24+
let min = ", stringify!($T), "::MIN;
25+
```
26+
"),
1627
#[$attr]
1728
pub const MIN: $T = $T::MIN;
1829
}
1930

2031
doc_comment! {
2132
concat!("The largest value that can be represented by this integer type.
22-
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."),
33+
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead.
34+
35+
# Examples
36+
37+
```rust
38+
// deprecated way
39+
let max = std::", stringify!($T), "::MAX;
40+
41+
// intended way
42+
let max = ", stringify!($T), "::MAX;
43+
```
44+
"),
2345
#[$attr]
2446
pub const MAX: $T = $T::MAX;
2547
}

0 commit comments

Comments
 (0)