about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-01 23:56:26 +0200
committerGitHub <noreply@github.com>2019-10-01 23:56:26 +0200
commit66148f6393d24da662bce6df3e7c6e3f2ee58bba (patch)
treef52b1203fd10a87bef197a9c326f10d914c9c4ab
parent67cbeee9ee2751f5da8312a3cefea77f44d72795 (diff)
parenteb4ca2120eb325054c28999ff421e3d9efe44802 (diff)
downloadrust-66148f6393d24da662bce6df3e7c6e3f2ee58bba.tar.gz
rust-66148f6393d24da662bce6df3e7c6e3f2ee58bba.zip
Rollup merge of #64943 - lzutao:doc-saturating, r=shepmaster
Add lower bound doctests for `saturating_{add,sub}` signed ints

Closes #64940
-rw-r--r--src/libcore/num/mod.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 933a2a12473..83ffa8f8a84 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -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")]