Skip to content

Commit

Permalink
Add examples to int macros
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed May 4, 2020
1 parent 8bef0a3 commit 55e37f9
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/libcore/num/int_macros.rs
Expand Up @@ -12,14 +12,36 @@ macro_rules! int_module {
($T:ident, #[$attr:meta]) => (
doc_comment! {
concat!("The smallest value that can be represented by this integer type.
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."),
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead.
# Examples
```rust
// deprecated way
let min = std::", stringify!($T), "::MIN;
// intended way
let min = ", stringify!($T), "::MIN;
```
"),
#[$attr]
pub const MIN: $T = $T::MIN;
}

doc_comment! {
concat!("The largest value that can be represented by this integer type.
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."),
Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead.
# Examples
```rust
// deprecated way
let max = std::", stringify!($T), "::MAX;
// intended way
let max = ", stringify!($T), "::MAX;
```
"),
#[$attr]
pub const MAX: $T = $T::MAX;
}
Expand Down

0 comments on commit 55e37f9

Please sign in to comment.