File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pub type SizeHint = (usize, Option<usize>);
10
10
/// Add **SizeHint** correctly.
11
11
#[ inline]
12
12
pub fn add ( a : SizeHint , b : SizeHint ) -> SizeHint {
13
- let min = a. 0 . checked_add ( b. 0 ) . unwrap_or ( usize :: MAX ) ;
13
+ let min = a. 0 . saturating_add ( b. 0 ) ;
14
14
let max = match ( a. 1 , b. 1 ) {
15
15
( Some ( x) , Some ( y) ) => x. checked_add ( y) ,
16
16
_ => None ,
@@ -56,7 +56,7 @@ pub fn sub_scalar(sh: SizeHint, x: usize) -> SizeHint {
56
56
/// ```
57
57
#[ inline]
58
58
pub fn mul ( a : SizeHint , b : SizeHint ) -> SizeHint {
59
- let low = a. 0 . checked_mul ( b. 0 ) . unwrap_or ( usize :: MAX ) ;
59
+ let low = a. 0 . saturating_mul ( b. 0 ) ;
60
60
let hi = match ( a. 1 , b. 1 ) {
61
61
( Some ( x) , Some ( y) ) => x. checked_mul ( y) ,
62
62
( Some ( 0 ) , None ) | ( None , Some ( 0 ) ) => Some ( 0 ) ,
You can’t perform that action at this time.
0 commit comments