File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -1304,30 +1304,27 @@ impl<T: Debug + PrimInt> Iterator for StorageIter<'_, T> {
13041304
13051305#[ inline( always) ]
13061306/// How many bits are stored in each underlying storage block?
1307- fn bits_per_block < T > ( ) -> usize {
1307+ const fn bits_per_block < T > ( ) -> usize {
13081308 bytes_per_block :: < T > ( ) * 8
13091309}
13101310
13111311#[ inline( always) ]
13121312/// How many bytes are stored in each underlying storage block?
1313- fn bytes_per_block < T > ( ) -> usize {
1313+ const fn bytes_per_block < T > ( ) -> usize {
13141314 size_of :: < T > ( )
13151315}
13161316
1317+ #[ inline( always) ]
13171318/// Return the offset in the vector of the storage block storing the bit `off`.
1318- fn block_offset < T > ( off : usize ) -> usize {
1319+ const fn block_offset < T > ( off : usize ) -> usize {
13191320 off / bits_per_block :: < T > ( )
13201321}
13211322
1323+ #[ inline( always) ]
13221324/// Takes as input a number of bits requiring storage; returns an aligned number of blocks needed
13231325/// to store those bits.
13241326fn blocks_required < T > ( num_bits : usize ) -> usize {
1325- num_bits / bits_per_block :: < T > ( )
1326- + if num_bits % bits_per_block :: < T > ( ) == 0 {
1327- 0
1328- } else {
1329- 1
1330- }
1327+ num_bits / bits_per_block :: < T > ( ) + usize:: from ( num_bits % bits_per_block :: < T > ( ) != 0 )
13311328}
13321329
13331330#[ macro_export]
You can’t perform that action at this time.
0 commit comments