Skip to content

Commit

Permalink
Rollup merge of rust-lang#64943 - lzutao:doc-saturating, r=shepmaster
Browse files Browse the repository at this point in the history
Add lower bound doctests for `saturating_{add,sub}` signed ints

Closes rust-lang#64940
  • Loading branch information
Centril authored Oct 1, 2019
2 parents 67cbeee + eb4ca21 commit 66148f6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,9 @@ Basic usage:
```
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);
assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT),
"::max_value());",
"::max_value());
assert_eq!(", stringify!($SelfT), "::min_value().saturating_add(-1), ", stringify!($SelfT),
"::min_value());",
$EndFeature, "
```"),

Expand All @@ -952,7 +954,6 @@ $EndFeature, "
}
}


doc_comment! {
concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the
numeric bounds instead of overflowing.
Expand All @@ -964,7 +965,9 @@ Basic usage:
```
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27);
assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT),
"::min_value());",
"::min_value());
assert_eq!(", stringify!($SelfT), "::max_value().saturating_sub(-1), ", stringify!($SelfT),
"::max_value());",
$EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit 66148f6

Please sign in to comment.