We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8b24964 + 550c87e commit c2b6ab9Copy full SHA for c2b6ab9
src/libnum/bigint.rs
@@ -230,7 +230,8 @@ impl Sub<BigUint, BigUint> for BigUint {
230
lo
231
}).collect();
232
233
- assert_eq!(borrow, 0); // <=> assert!((self >= other));
+ assert!(borrow == 0,
234
+ "Cannot subtract other from self because other is larger than self.");
235
return BigUint::new(diff);
236
}
237
@@ -1755,6 +1756,13 @@ mod biguint_tests {
1755
1756
1757
1758
1759
+ #[test]
1760
+ #[should_fail]
1761
+ fn test_sub_fail_on_underflow() {
1762
+ let (a, b) : (BigUint, BigUint) = (Zero::zero(), One::one());
1763
+ a - b;
1764
+ }
1765
+
1766
static mul_triples: &'static [(&'static [BigDigit],
1767
&'static [BigDigit],
1768
&'static [BigDigit])] = &[
0 commit comments