Add lower bound doctests for `saturating_{add,sub}` signed ints

This commit is contained in:
Lzu Tao 2019-10-01 05:46:50 +00:00
parent 22bc9e1d9c
commit eb4ca2120e
1 changed files with 6 additions and 3 deletions

View File

@ -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, "
```"),
@ -952,7 +954,6 @@ $EndFeature, "
}
}
doc_comment! {
concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the
numeric bounds instead of overflowing.
@ -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")]