Skip to content

Commit 6eee5a8

Browse files
committed
use usize::from instead of casting
1 parent 5be7446 commit 6eee5a8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/structures/idt.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,13 @@ impl InterruptDescriptorTable {
466466
/// Panics if the entry is an exception.
467467
fn condition_slice_bounds(&self, bounds: impl RangeBounds<u8>) -> (usize, usize) {
468468
let lower_idx = match bounds.start_bound() {
469-
Included(start) => (*start as usize),
470-
Excluded(start) => (*start as usize) + 1,
469+
Included(start) => usize::from(*start),
470+
Excluded(start) => usize::from(*start) + 1,
471471
Unbounded => 0,
472472
};
473473
let upper_idx = match bounds.end_bound() {
474-
Included(end) => (*end as usize) + 1,
475-
Excluded(end) => (*end as usize),
474+
Included(end) => usize::from(*end) + 1,
475+
Excluded(end) => usize::from(*end),
476476
Unbounded => 256,
477477
};
478478

@@ -522,7 +522,7 @@ impl Index<u8> for InterruptDescriptorTable {
522522
16 => &self.x87_floating_point,
523523
19 => &self.simd_floating_point,
524524
20 => &self.virtualization,
525-
i @ 32..=255 => &self.interrupts[(i - 32) as usize],
525+
i @ 32..=255 => &self.interrupts[usize::from(i - 32)],
526526
i @ 15 | i @ 31 | i @ 21..=29 => panic!("entry {} is reserved", i),
527527
i @ 8 | i @ 10..=14 | i @ 17 | i @ 30 => {
528528
panic!("entry {} is an exception with error code", i)
@@ -551,7 +551,7 @@ impl IndexMut<u8> for InterruptDescriptorTable {
551551
16 => &mut self.x87_floating_point,
552552
19 => &mut self.simd_floating_point,
553553
20 => &mut self.virtualization,
554-
i @ 32..=255 => &mut self.interrupts[(i - 32) as usize],
554+
i @ 32..=255 => &mut self.interrupts[usize::from(i - 32)],
555555
i @ 15 | i @ 31 | i @ 21..=29 => panic!("entry {} is reserved", i),
556556
i @ 8 | i @ 10..=14 | i @ 17 | i @ 30 => {
557557
panic!("entry {} is an exception with error code", i)

0 commit comments

Comments
 (0)