@@ -560,7 +560,7 @@ impl IndexMut<usize> for InterruptDescriptorTable {
560
560
///
561
561
/// The generic parameter can either be `HandlerFunc` or `HandlerFuncWithErrCode`, depending
562
562
/// on the interrupt vector.
563
- #[ derive( Debug , Clone , Copy , PartialEq ) ]
563
+ #[ derive( Clone , Copy ) ]
564
564
#[ repr( C ) ]
565
565
pub struct Entry < F > {
566
566
pointer_low : u16 ,
@@ -572,6 +572,30 @@ pub struct Entry<F> {
572
572
phantom : PhantomData < F > ,
573
573
}
574
574
575
+ impl < T > fmt:: Debug for Entry < T > {
576
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
577
+ f. debug_struct ( "Entry" )
578
+ . field ( "pointer_low" , & self . pointer_low )
579
+ . field ( "gdt_selector" , & self . gdt_selector )
580
+ . field ( "options" , & self . options )
581
+ . field ( "pointer_middle" , & self . pointer_middle )
582
+ . field ( "pointer_high" , & self . pointer_high )
583
+ . field ( "reserved" , & self . reserved )
584
+ . finish ( )
585
+ }
586
+ }
587
+
588
+ impl < T > PartialEq for Entry < T > {
589
+ fn eq ( & self , other : & Self ) -> bool {
590
+ self . pointer_low == other. pointer_low
591
+ && self . gdt_selector == other. gdt_selector
592
+ && self . options == other. options
593
+ && self . pointer_middle == other. pointer_middle
594
+ && self . pointer_high == other. pointer_high
595
+ && self . reserved == other. reserved
596
+ }
597
+ }
598
+
575
599
/// A handler function for an interrupt or an exception without error code.
576
600
pub type HandlerFunc = extern "x86-interrupt" fn ( InterruptStackFrame ) ;
577
601
/// A handler function for an exception that pushes an error code.
@@ -833,4 +857,19 @@ mod test {
833
857
assert_eq ! ( size_of:: <Entry <HandlerFunc >>( ) , 16 ) ;
834
858
assert_eq ! ( size_of:: <InterruptDescriptorTable >( ) , 256 * 16 ) ;
835
859
}
860
+
861
+ #[ test]
862
+ fn entry_derive_test ( ) {
863
+ fn foo ( _: impl Clone + Copy + PartialEq + fmt:: Debug ) { }
864
+
865
+ foo ( Entry :: < HandlerFuncWithErrCode > {
866
+ pointer_low : 0 ,
867
+ gdt_selector : 0 ,
868
+ options : EntryOptions ( 0 ) ,
869
+ pointer_middle : 0 ,
870
+ pointer_high : 0 ,
871
+ reserved : 0 ,
872
+ phantom : PhantomData ,
873
+ } )
874
+ }
836
875
}
0 commit comments