Skip to content

Commit f66b706

Browse files
committed
clippy
1 parent b04920d commit f66b706

File tree

8 files changed

+63
-65
lines changed

8 files changed

+63
-65
lines changed

src/binwt/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn craft_wm_codes(freq: &mut HashMap<usize, u32>, sigma: usize) -> Vec<PrefixCod
6565
reversed_code |= ((c[j] >> t) & 1) << (l - t - 1);
6666
}
6767

68-
assignments[f[j].0 as usize] = PrefixCode {
68+
assignments[f[j].0] = PrefixCode {
6969
content: reversed_code,
7070
len: l,
7171
};
@@ -176,7 +176,7 @@ where
176176

177177
for &s in sequence.iter() {
178178
if COMPRESSED {
179-
let cur_code = codes_encode.as_ref().unwrap().get(s.as_() as usize).expect(
179+
let cur_code = codes_encode.as_ref().unwrap().get(s.as_()).expect(
180180
"some error occurred during code translation while building huffqwt",
181181
);
182182

@@ -312,7 +312,7 @@ where
312312
{
313313
type Item = T;
314314

315-
#[must_use]
315+
316316
#[inline(always)]
317317
fn get(&self, i: usize) -> Option<Self::Item> {
318318
if i >= self.n {
@@ -377,7 +377,7 @@ where
377377

378378
if COMPRESSED
379379
&& (symbol.as_() >= self.codes_encode.as_ref().unwrap().len()
380-
|| self.codes_encode.as_ref().unwrap()[symbol.as_() as usize].len == 0)
380+
|| self.codes_encode.as_ref().unwrap()[symbol.as_()].len == 0)
381381
{
382382
return None;
383383
}
@@ -394,7 +394,7 @@ where
394394
let repr;
395395

396396
if COMPRESSED {
397-
let code = &self.codes_encode.as_ref().unwrap()[symbol.as_() as usize];
397+
let code = &self.codes_encode.as_ref().unwrap()[symbol.as_()];
398398
symbol_len = code.len as usize;
399399
repr = code.content;
400400
} else {
@@ -427,15 +427,15 @@ where
427427
{
428428
#[inline(always)]
429429
fn select(&self, symbol: Self::Item, i: usize) -> Option<usize> {
430-
if COMPRESSED && self.codes_encode.as_ref().unwrap()[symbol.as_() as usize].len == 0 {
430+
if COMPRESSED && self.codes_encode.as_ref().unwrap()[symbol.as_()].len == 0 {
431431
return None;
432432
}
433433

434434
let symbol_len;
435435
let repr;
436436

437437
if COMPRESSED {
438-
let code = &self.codes_encode.as_ref().unwrap()[symbol.as_() as usize];
438+
let code = &self.codes_encode.as_ref().unwrap()[symbol.as_()];
439439
symbol_len = code.len as usize;
440440
repr = code.content;
441441
} else {

src/bitvector/mod.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl BitVector {
271271
///
272272
/// ```
273273
#[must_use]
274-
pub fn ones(&self) -> BitVectorBitPositionsIter<true> {
274+
pub fn ones(&self) -> BitVectorBitPositionsIter<'_, true> {
275275
BitVectorBitPositionsIter::new(cast_to_u64_slice(&self.data), self.n_bits)
276276
}
277277

@@ -289,7 +289,7 @@ impl BitVector {
289289
/// assert_eq!(v, vec![63, 128, 129, 254, 1026]);
290290
/// ```
291291
#[must_use]
292-
pub fn ones_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<true> {
292+
pub fn ones_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<'_, true> {
293293
BitVectorBitPositionsIter::with_pos(cast_to_u64_slice(&self.data), self.n_bits, pos)
294294
}
295295

@@ -308,13 +308,13 @@ impl BitVector {
308308
/// assert_eq!(v, negate_vector(&vv));
309309
/// ```
310310
#[must_use]
311-
pub fn zeros(&self) -> BitVectorBitPositionsIter<false> {
311+
pub fn zeros(&self) -> BitVectorBitPositionsIter<'_, false> {
312312
BitVectorBitPositionsIter::new(cast_to_u64_slice(&self.data), self.n_bits)
313313
}
314314

315315
/// Returns a non-consuming iterator over positions of bits set to 0 in the bit vector, starting at a specified bit position.
316316
#[must_use]
317-
pub fn zeros_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<false> {
317+
pub fn zeros_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<'_, false> {
318318
BitVectorBitPositionsIter::with_pos(cast_to_u64_slice(&self.data), self.n_bits, pos)
319319
}
320320

@@ -337,7 +337,7 @@ impl BitVector {
337337
/// assert_eq!(iter.next(), Some(true)); // Sixth bit is true
338338
/// assert_eq!(iter.next(), None); // End of the iterator
339339
/// ```
340-
pub fn iter(&self) -> BitVectorIter {
340+
pub fn iter(&self) -> BitVectorIter<'_> {
341341
BitVectorIter {
342342
data: cast_to_u64_slice(&self.data),
343343
n_bits: self.n_bits,
@@ -447,7 +447,7 @@ impl AccessBin for BitVector {
447447
/// assert_eq!(bv.get(1), Some(false));
448448
/// assert_eq!(bv.get(10), None);
449449
/// ```
450-
#[must_use]
450+
451451
#[inline(always)]
452452
fn get(&self, index: usize) -> Option<bool> {
453453
if index >= self.len() {
@@ -470,7 +470,7 @@ impl AccessBin for BitVector {
470470
///
471471
/// assert_eq!(unsafe{bv.get_unchecked(5)}, true);
472472
/// ```
473-
#[must_use]
473+
474474
#[inline(always)]
475475
unsafe fn get_unchecked(&self, index: usize) -> bool {
476476
BitVectorMut::get_bit_slice(cast_to_u64_slice(&self.data), index)
@@ -535,7 +535,6 @@ where
535535
V: MyPrimInt,
536536
<V as TryInto<usize>>::Error: std::fmt::Debug,
537537
{
538-
#[must_use]
539538
fn from_iter<T>(iter: T) -> Self
540539
where
541540
T: IntoIterator<Item = V>,
@@ -822,7 +821,7 @@ impl BitVectorMut {
822821
/// ```
823822
#[must_use]
824823
pub fn with_capacity(n_bits: usize) -> Self {
825-
let capacity = (n_bits + 63) / 64;
824+
let capacity = n_bits.div_ceil(64);
826825
Self {
827826
data: Vec::with_capacity(capacity),
828827
..Self::default()
@@ -954,7 +953,7 @@ impl BitVectorMut {
954953
#[inline]
955954
pub fn extend_with_zeros(&mut self, n: usize) {
956955
self.n_bits += n;
957-
let new_size = (self.n_bits + 511) / 512;
956+
let new_size = self.n_bits.div_ceil(512);
958957
self.data.resize_with(new_size, Default::default);
959958
}
960959

@@ -1179,7 +1178,7 @@ impl BitVectorMut {
11791178
/// assert_eq!(v, vv);
11801179
/// ```
11811180
#[must_use]
1182-
pub fn ones(&self) -> BitVectorBitPositionsIter<true> {
1181+
pub fn ones(&self) -> BitVectorBitPositionsIter<'_, true> {
11831182
BitVectorBitPositionsIter::new(cast_to_u64_slice(&self.data), self.n_bits)
11841183
}
11851184

@@ -1197,7 +1196,7 @@ impl BitVectorMut {
11971196
/// assert_eq!(v, vec![63, 128, 129, 254, 1026]);
11981197
/// ```
11991198
#[must_use]
1200-
pub fn ones_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<true> {
1199+
pub fn ones_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<'_, true> {
12011200
BitVectorBitPositionsIter::with_pos(cast_to_u64_slice(&self.data), self.n_bits, pos)
12021201
}
12031202

@@ -1216,13 +1215,13 @@ impl BitVectorMut {
12161215
/// assert_eq!(v, negate_vector(&vv));
12171216
/// ```
12181217
#[must_use]
1219-
pub fn zeros(&self) -> BitVectorBitPositionsIter<false> {
1218+
pub fn zeros(&self) -> BitVectorBitPositionsIter<'_, false> {
12201219
BitVectorBitPositionsIter::new(cast_to_u64_slice(&self.data), self.n_bits)
12211220
}
12221221

12231222
/// Returns a non-consuming iterator over positions of bits set to 0 in the bit vector, starting at a specified bit position.
12241223
#[must_use]
1225-
pub fn zeros_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<false> {
1224+
pub fn zeros_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<'_, false> {
12261225
BitVectorBitPositionsIter::with_pos(cast_to_u64_slice(&self.data), self.n_bits, pos)
12271226
}
12281227

@@ -1245,7 +1244,7 @@ impl BitVectorMut {
12451244
/// assert_eq!(iter.next(), Some(true)); // Sixth bit is true
12461245
/// assert_eq!(iter.next(), None); // End of the iterator
12471246
/// ```
1248-
pub fn iter(&self) -> BitVectorIter {
1247+
pub fn iter(&self) -> BitVectorIter<'_> {
12491248
BitVectorIter {
12501249
data: cast_to_u64_slice(&self.data),
12511250
n_bits: self.n_bits,
@@ -1357,7 +1356,7 @@ impl AccessBin for BitVectorMut {
13571356
/// assert_eq!(bv.get(8), Some(false));
13581357
/// assert_eq!(bv.get(10), None);
13591358
/// ```
1360-
#[must_use]
1359+
13611360
#[inline(always)]
13621361
fn get(&self, index: usize) -> Option<bool> {
13631362
if index >= self.len() {
@@ -1379,7 +1378,7 @@ impl AccessBin for BitVectorMut {
13791378
/// bv.extend_with_zeros(10);
13801379
/// assert_eq!(unsafe{bv.get_unchecked(8)}, false);
13811380
/// ```
1382-
#[must_use]
1381+
13831382
#[inline(always)]
13841383
unsafe fn get_unchecked(&self, index: usize) -> bool {
13851384
Self::get_bit_slice(cast_to_u64_slice(&self.data), index)

src/bitvector/rs_narrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl RSNarrow {
8383
}
8484
block_rank_pairs.push(subranks);
8585

86-
if bv.data.len() % BLOCK_SIZE > 0 {
86+
if !bv.data.len().is_multiple_of(BLOCK_SIZE) {
8787
block_rank_pairs.push(next_rank);
8888
block_rank_pairs.push(0);
8989
}

src/darray/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<const BIT: bool> Inventories<BIT> {
177177
let v: i64 = (-(overflow_positions.len() as i64)) - 1;
178178
block_inventory.push(v);
179179
overflow_positions.extend(curr_positions.iter());
180-
subblock_inventory.extend(std::iter::repeat(u16::MAX).take(curr_positions.len()));
180+
subblock_inventory.extend(std::iter::repeat_n(u16::MAX, curr_positions.len()));
181181
}
182182
}
183183
}
@@ -227,7 +227,7 @@ impl<const SELECT0_SUPPORT: bool> DArray<SELECT0_SUPPORT> {
227227
/// assert_eq!(v, vv);
228228
/// ```
229229
#[must_use]
230-
pub fn ones(&self) -> BitVectorBitPositionsIter<true> {
230+
pub fn ones(&self) -> BitVectorBitPositionsIter<'_, true> {
231231
self.bv.ones()
232232
}
233233

@@ -245,7 +245,7 @@ impl<const SELECT0_SUPPORT: bool> DArray<SELECT0_SUPPORT> {
245245
/// assert_eq!(v, vec![63, 128, 129, 254, 1026]);
246246
/// ```
247247
#[must_use]
248-
pub fn ones_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<true> {
248+
pub fn ones_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<'_, true> {
249249
self.bv.ones_with_pos(pos)
250250
}
251251

@@ -264,13 +264,13 @@ impl<const SELECT0_SUPPORT: bool> DArray<SELECT0_SUPPORT> {
264264
/// assert_eq!(v, negate_vector(&vv));
265265
/// ```
266266
#[must_use]
267-
pub fn zeros(&self) -> BitVectorBitPositionsIter<false> {
267+
pub fn zeros(&self) -> BitVectorBitPositionsIter<'_, false> {
268268
self.bv.zeros()
269269
}
270270

271271
/// Returns a non-consuming iterator over positions of bits set to 0 in the bit vector, starting at a specified bit position.
272272
#[must_use]
273-
pub fn zeros_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<false> {
273+
pub fn zeros_with_pos(&self, pos: usize) -> BitVectorBitPositionsIter<'_, false> {
274274
self.bv.zeros_with_pos(pos)
275275
}
276276

@@ -293,7 +293,7 @@ impl<const SELECT0_SUPPORT: bool> DArray<SELECT0_SUPPORT> {
293293
/// assert_eq!(iter.next(), Some(true)); // Sixth bit is true
294294
/// assert_eq!(iter.next(), None); // End of the iterator
295295
/// ```
296-
pub fn iter(&self) -> BitVectorIter {
296+
pub fn iter(&self) -> BitVectorIter<'_> {
297297
self.bv.iter()
298298
}
299299

@@ -438,7 +438,7 @@ impl<const SELECT0_SUPPORT: bool> AccessBin for DArray<SELECT0_SUPPORT> {
438438
/// assert_eq!(da.get(1), Some(false));
439439
/// assert_eq!(da.get(10), None);
440440
/// ```
441-
#[must_use]
441+
442442
#[inline(always)]
443443
fn get(&self, i: usize) -> Option<bool> {
444444
self.bv.get(i)
@@ -457,7 +457,7 @@ impl<const SELECT0_SUPPORT: bool> AccessBin for DArray<SELECT0_SUPPORT> {
457457
/// let da: DArray = v.into_iter().collect();;
458458
/// assert_eq!(unsafe{da.get_unchecked(8)}, false);
459459
/// ```
460-
#[must_use]
460+
461461
#[inline(always)]
462462
unsafe fn get_unchecked(&self, i: usize) -> bool {
463463
self.bv.get_unchecked(i)
@@ -482,7 +482,7 @@ impl<const SELECT0_SUPPORT: bool> SelectBin for DArray<SELECT0_SUPPORT> {
482482
///
483483
/// # Panics
484484
/// It panics if [`DArray`] is built without support for `select0`query.
485-
#[must_use]
485+
486486
#[inline(always)]
487487
fn select1(&self, i: usize) -> Option<usize> {
488488
self.select(i, &self.ones_inventories)
@@ -502,7 +502,7 @@ impl<const SELECT0_SUPPORT: bool> SelectBin for DArray<SELECT0_SUPPORT> {
502502
///
503503
/// assert_eq!(unsafe{da.select1_unchecked(1)}, 12);
504504
/// ```
505-
#[must_use]
505+
506506
#[inline(always)]
507507
unsafe fn select1_unchecked(&self, i: usize) -> usize {
508508
self.select(i, &self.ones_inventories).unwrap()
@@ -526,7 +526,7 @@ impl<const SELECT0_SUPPORT: bool> SelectBin for DArray<SELECT0_SUPPORT> {
526526
///
527527
/// # Panics
528528
/// It panics if [`DArray`] is built without support for `select0`query.
529-
#[must_use]
529+
530530
#[inline(always)]
531531
fn select0(&self, i: usize) -> Option<usize> {
532532
assert!(SELECT0_SUPPORT);
@@ -601,7 +601,7 @@ where
601601
V: crate::bitvector::MyPrimInt + PartialOrd,
602602
<V as TryInto<usize>>::Error: std::fmt::Debug,
603603
{
604-
#[must_use]
604+
605605
fn from_iter<T>(iter: T) -> Self
606606
where
607607
T: IntoIterator<Item = V>,

0 commit comments

Comments
 (0)