@@ -504,15 +504,14 @@ impl InterruptDescriptorTable {
504504 }
505505}
506506
507- impl Index < usize > for InterruptDescriptorTable {
507+ impl Index < u8 > for InterruptDescriptorTable {
508508 type Output = Entry < HandlerFunc > ;
509509
510510 /// Returns the IDT entry with the specified index.
511511 ///
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).
514513 #[ inline]
515- fn index ( & self , index : usize ) -> & Self :: Output {
514+ fn index ( & self , index : u8 ) -> & Self :: Output {
516515 match index {
517516 0 => & self . divide_error ,
518517 1 => & self . debug ,
@@ -526,24 +525,22 @@ impl Index<usize> for InterruptDescriptorTable {
526525 16 => & self . x87_floating_point ,
527526 19 => & self . simd_floating_point ,
528527 20 => & self . virtualization ,
529- i @ 32 ..=255 => & self . interrupts [ i - 32 ] ,
528+ i @ 32 ..=255 => & self . interrupts [ ( i - 32 ) as usize ] ,
530529 i @ 15 | i @ 31 | i @ 21 ..=29 => panic ! ( "entry {} is reserved" , i) ,
531530 i @ 8 | i @ 10 ..=14 | i @ 17 | i @ 30 => {
532531 panic ! ( "entry {} is an exception with error code" , i)
533532 }
534533 i @ 18 => panic ! ( "entry {} is an diverging exception (must not return)" , i) ,
535- i => panic ! ( "no entry with index {}" , i) ,
536534 }
537535 }
538536}
539537
540- impl IndexMut < usize > for InterruptDescriptorTable {
538+ impl IndexMut < u8 > for InterruptDescriptorTable {
541539 /// Returns a mutable reference to the IDT entry with the specified index.
542540 ///
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).
545542 #[ inline]
546- fn index_mut ( & mut self , index : usize ) -> & mut Self :: Output {
543+ fn index_mut ( & mut self , index : u8 ) -> & mut Self :: Output {
547544 match index {
548545 0 => & mut self . divide_error ,
549546 1 => & mut self . debug ,
@@ -557,13 +554,12 @@ impl IndexMut<usize> for InterruptDescriptorTable {
557554 16 => & mut self . x87_floating_point ,
558555 19 => & mut self . simd_floating_point ,
559556 20 => & mut self . virtualization ,
560- i @ 32 ..=255 => & mut self . interrupts [ i - 32 ] ,
557+ i @ 32 ..=255 => & mut self . interrupts [ ( i - 32 ) as usize ] ,
561558 i @ 15 | i @ 31 | i @ 21 ..=29 => panic ! ( "entry {} is reserved" , i) ,
562559 i @ 8 | i @ 10 ..=14 | i @ 17 | i @ 30 => {
563560 panic ! ( "entry {} is an exception with error code" , i)
564561 }
565562 i @ 18 => panic ! ( "entry {} is an diverging exception (must not return)" , i) ,
566- i => panic ! ( "no entry with index {}" , i) ,
567563 }
568564 }
569565}
0 commit comments