@@ -504,15 +504,14 @@ impl InterruptDescriptorTable {
504
504
}
505
505
}
506
506
507
- impl Index < usize > for InterruptDescriptorTable {
507
+ impl Index < u8 > for InterruptDescriptorTable {
508
508
type Output = Entry < HandlerFunc > ;
509
509
510
510
/// Returns the IDT entry with the specified index.
511
511
///
512
- /// Panics if index is outside the IDT (i.e. greater than 255) or if the entry is an
513
- /// exception that pushes an error code (use the struct fields for accessing these entries).
512
+ /// Panics if the entry is an exception that pushes an error code (use the struct fields for accessing these entries).
514
513
#[ inline]
515
- fn index ( & self , index : usize ) -> & Self :: Output {
514
+ fn index ( & self , index : u8 ) -> & Self :: Output {
516
515
match index {
517
516
0 => & self . divide_error ,
518
517
1 => & self . debug ,
@@ -526,24 +525,22 @@ impl Index<usize> for InterruptDescriptorTable {
526
525
16 => & self . x87_floating_point ,
527
526
19 => & self . simd_floating_point ,
528
527
20 => & self . virtualization ,
529
- i @ 32 ..=255 => & self . interrupts [ i - 32 ] ,
528
+ i @ 32 ..=255 => & self . interrupts [ ( i - 32 ) as usize ] ,
530
529
i @ 15 | i @ 31 | i @ 21 ..=29 => panic ! ( "entry {} is reserved" , i) ,
531
530
i @ 8 | i @ 10 ..=14 | i @ 17 | i @ 30 => {
532
531
panic ! ( "entry {} is an exception with error code" , i)
533
532
}
534
533
i @ 18 => panic ! ( "entry {} is an diverging exception (must not return)" , i) ,
535
- i => panic ! ( "no entry with index {}" , i) ,
536
534
}
537
535
}
538
536
}
539
537
540
- impl IndexMut < usize > for InterruptDescriptorTable {
538
+ impl IndexMut < u8 > for InterruptDescriptorTable {
541
539
/// Returns a mutable reference to the IDT entry with the specified index.
542
540
///
543
- /// Panics if index is outside the IDT (i.e. greater than 255) or if the entry is an
544
- /// exception that pushes an error code (use the struct fields for accessing these entries).
541
+ /// Panics if the entry is an exception that pushes an error code (use the struct fields for accessing these entries).
545
542
#[ inline]
546
- fn index_mut ( & mut self , index : usize ) -> & mut Self :: Output {
543
+ fn index_mut ( & mut self , index : u8 ) -> & mut Self :: Output {
547
544
match index {
548
545
0 => & mut self . divide_error ,
549
546
1 => & mut self . debug ,
@@ -557,13 +554,12 @@ impl IndexMut<usize> for InterruptDescriptorTable {
557
554
16 => & mut self . x87_floating_point ,
558
555
19 => & mut self . simd_floating_point ,
559
556
20 => & mut self . virtualization ,
560
- i @ 32 ..=255 => & mut self . interrupts [ i - 32 ] ,
557
+ i @ 32 ..=255 => & mut self . interrupts [ ( i - 32 ) as usize ] ,
561
558
i @ 15 | i @ 31 | i @ 21 ..=29 => panic ! ( "entry {} is reserved" , i) ,
562
559
i @ 8 | i @ 10 ..=14 | i @ 17 | i @ 30 => {
563
560
panic ! ( "entry {} is an exception with error code" , i)
564
561
}
565
562
i @ 18 => panic ! ( "entry {} is an diverging exception (must not return)" , i) ,
566
- i => panic ! ( "no entry with index {}" , i) ,
567
563
}
568
564
}
569
565
}
0 commit comments