Skip to content

Commit 440d4f3

Browse files
committed
Clippy suggestions
1 parent 81a9fbd commit 440d4f3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/mmap_bitvec.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl MmapBitVec {
192192
io::ErrorKind::InvalidData,
193193
format!(
194194
"file should be {} bytes (with {} header), but file is {} bytes",
195-
byte_size + total_header_size as u64,
195+
byte_size + total_header_size,
196196
total_header_size,
197197
file.metadata()?.len(),
198198
),
@@ -282,9 +282,9 @@ impl MmapBitVec {
282282
if r.end > self.size {
283283
panic!("Range ends outside of BitVec")
284284
}
285-
let byte_idx_st = (r.start >> 3) as usize;
286-
let byte_idx_en = ((r.end - 1) >> 3) as usize;
287-
let new_size: usize = (((r.end - r.start) as usize - 1) >> 3) + 1;
285+
let byte_idx_st = r.start >> 3;
286+
let byte_idx_en = (r.end - 1) >> 3;
287+
let new_size: usize = (((r.end - r.start) - 1) >> 3) + 1;
288288

289289
let ptr: *const u8 = self.mmap.as_ptr();
290290
let mut v = vec![0; new_size];
@@ -333,7 +333,7 @@ impl MmapBitVec {
333333
} else {
334334
0
335335
};
336-
let byte_idx_en = ((r.end - 1) >> 3) as usize;
336+
let byte_idx_en = (r.end - 1) >> 3;
337337

338338
let mmap: *mut u8 = self
339339
.mmap
@@ -406,8 +406,8 @@ impl BitVector for MmapBitVec {
406406

407407
/// Return the number of set bits in the range `r`
408408
fn rank(&self, r: Range<usize>) -> usize {
409-
let byte_idx_st = (r.start >> 3) as usize;
410-
let byte_idx_en = ((r.end - 1) >> 3) as usize;
409+
let byte_idx_st = r.start >> 3;
410+
let byte_idx_en = (r.end - 1) >> 3;
411411
let mmap: *const u8 = self.mmap.as_ptr();
412412

413413
let mut bit_count = 0usize;
@@ -452,7 +452,7 @@ impl BitVector for MmapBitVec {
452452

453453
/// Return the position of the `nth` set bit with `start` treated as the 0th position, or `None` if there is no set bit
454454
fn select(&self, n: usize, start: usize) -> Option<usize> {
455-
let byte_idx_st = (start >> 3) as usize;
455+
let byte_idx_st = start >> 3;
456456
let size_front = 8u8 - (start & 7) as u8;
457457
let mmap: *const u8 = self.mmap.as_ptr();
458458

@@ -494,8 +494,8 @@ impl BitVector for MmapBitVec {
494494
} else if r.end > self.size {
495495
panic!("Range ends outside of BitVec")
496496
}
497-
let byte_idx_st = (r.start >> 3) as usize;
498-
let byte_idx_en = ((r.end - 1) >> 3) as usize;
497+
let byte_idx_st = r.start >> 3;
498+
let byte_idx_en = (r.end - 1) >> 3;
499499
let new_size: u8 = (r.end - r.start) as u8;
500500

501501
let mut v;
@@ -542,8 +542,8 @@ impl BitVector for MmapBitVec {
542542
if r.end > self.size {
543543
panic!("Range ends outside of BitVec")
544544
}
545-
let byte_idx_st = (r.start >> 3) as usize;
546-
let byte_idx_en = ((r.end - 1) >> 3) as usize;
545+
let byte_idx_st = r.start >> 3;
546+
let byte_idx_en = (r.end - 1) >> 3;
547547
let new_size: u8 = (r.end - r.start) as u8;
548548

549549
// split off the front byte
@@ -602,8 +602,8 @@ impl BitVector for MmapBitVec {
602602
if (r.end - 1) > self.size {
603603
panic!("Range ends outside of BitVec")
604604
}
605-
let byte_idx_st = (r.start >> 3) as usize;
606-
let byte_idx_en = ((r.end - 1) >> 3) as usize;
605+
let byte_idx_st = r.start >> 3;
606+
let byte_idx_en = (r.end - 1) >> 3;
607607

608608
let mmap: *mut u8 = self
609609
.mmap

0 commit comments

Comments
 (0)