File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020/// Returns the nearest number that is `>=` than `num` and is a multiple of 64
2121#[ inline]
2222pub fn round_upto_multiple_of_64 ( num : usize ) -> usize {
23- round_upto_power_of_2 ( num, 64 )
23+ num. checked_next_multiple_of ( 64 )
24+ . expect ( "failed to round upto multiple of 64" )
2425}
2526
2627/// Returns the nearest multiple of `factor` that is `>=` than `num`. Here `factor` must
@@ -86,9 +87,7 @@ pub unsafe fn unset_bit_raw(data: *mut u8, i: usize) {
8687/// Returns the ceil of `value`/`divisor`
8788#[ inline]
8889pub fn ceil ( value : usize , divisor : usize ) -> usize {
89- // Rewrite as `value.div_ceil(&divisor)` after
90- // https://github.com/rust-lang/rust/issues/88581 is merged.
91- value / divisor + ( 0 != value % divisor) as usize
90+ value. div_ceil ( divisor)
9291}
9392
9493#[ cfg( test) ]
@@ -109,6 +108,12 @@ mod tests {
109108 assert_eq ! ( 192 , round_upto_multiple_of_64( 129 ) ) ;
110109 }
111110
111+ #[ test]
112+ #[ should_panic( expected = "failed to round upto multiple of 64" ) ]
113+ fn test_round_upto_multiple_of_64_panic ( ) {
114+ let _ = round_upto_multiple_of_64 ( usize:: MAX ) ;
115+ }
116+
112117 #[ test]
113118 #[ should_panic( expected = "failed to round to next highest power of 2" ) ]
114119 fn test_round_upto_panic ( ) {
You can’t perform that action at this time.
0 commit comments