Skip to content

Commit eb4ca21

Browse files
committed
Add lower bound doctests for saturating_{add,sub} signed ints
1 parent 22bc9e1 commit eb4ca21

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libcore/num/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,9 @@ Basic usage:
938938
```
939939
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);
940940
assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT),
941-
"::max_value());",
941+
"::max_value());
942+
assert_eq!(", stringify!($SelfT), "::min_value().saturating_add(-1), ", stringify!($SelfT),
943+
"::min_value());",
942944
$EndFeature, "
943945
```"),
944946

@@ -952,7 +954,6 @@ $EndFeature, "
952954
}
953955
}
954956

955-
956957
doc_comment! {
957958
concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the
958959
numeric bounds instead of overflowing.
@@ -964,7 +965,9 @@ Basic usage:
964965
```
965966
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27);
966967
assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT),
967-
"::min_value());",
968+
"::min_value());
969+
assert_eq!(", stringify!($SelfT), "::max_value().saturating_sub(-1), ", stringify!($SelfT),
970+
"::max_value());",
968971
$EndFeature, "
969972
```"),
970973
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)