@@ -29,50 +29,52 @@ allowed! {
29
29
}
30
30
impl Allowed {
31
31
/// Sets the value of the Interrupt On Completion field.
32
- // Unavoidable because the match arms has to be the same return types.
33
- #[ allow( clippy:: too_many_lines) ]
34
32
pub fn set_interrupt_on_completion ( & mut self , ioc : bool ) {
35
- match self {
36
- Allowed :: Normal ( ref mut n) => {
37
- n. set_interrupt_on_completion ( ioc) ;
38
- }
39
- Allowed :: SetupStage ( ref mut s) => {
40
- s. set_interrupt_on_completion ( ioc) ;
41
- }
42
- Allowed :: DataStage ( ref mut d) => {
43
- d. set_interrupt_on_completion ( ioc) ;
44
- }
45
- Allowed :: StatusStage ( ref mut s) => {
46
- s. set_interrupt_on_completion ( ioc) ;
47
- }
48
- Allowed :: Isoch ( ref mut i) => {
49
- i. set_interrupt_on_completion ( ioc) ;
50
- }
51
- Allowed :: Link ( ref mut l) => {
52
- l. set_interrupt_on_completion ( ioc) ;
53
- }
54
- Allowed :: EventData ( ref mut e) => {
55
- e. set_interrupt_on_completion ( ioc) ;
56
- }
57
- Allowed :: Noop ( ref mut n) => {
58
- n. set_interrupt_on_completion ( ioc) ;
59
- }
33
+ macro_rules! arm{
34
+ ( $( $variant: ident) ,* ) =>{
35
+ match self {
36
+ $( Self :: $variant( ref mut x) =>{
37
+ x. set_interrupt_on_completion( ioc) ;
38
+ } , ) *
39
+ }
40
+ } ;
60
41
}
42
+
43
+ arm ! (
44
+ Normal ,
45
+ SetupStage ,
46
+ DataStage ,
47
+ StatusStage ,
48
+ Isoch ,
49
+ Link ,
50
+ EventData ,
51
+ Noop
52
+ ) ;
61
53
}
62
54
63
55
/// Returns the value of the Interrupt On Completion field.
64
56
#[ must_use]
65
57
pub fn interrupt_on_completion ( & self ) -> bool {
66
- match self {
67
- Allowed :: Normal ( n) => n. interrupt_on_completion ( ) ,
68
- Allowed :: SetupStage ( s) => s. interrupt_on_completion ( ) ,
69
- Allowed :: DataStage ( d) => d. interrupt_on_completion ( ) ,
70
- Allowed :: StatusStage ( s) => s. interrupt_on_completion ( ) ,
71
- Allowed :: Isoch ( i) => i. interrupt_on_completion ( ) ,
72
- Allowed :: Link ( l) => l. interrupt_on_completion ( ) ,
73
- Allowed :: EventData ( e) => e. interrupt_on_completion ( ) ,
74
- Allowed :: Noop ( n) => n. interrupt_on_completion ( ) ,
58
+ macro_rules! arm{
59
+ ( $( $variant: ident) ,* ) =>{
60
+ match self {
61
+ $( Self :: $variant( x) =>{
62
+ x. interrupt_on_completion( )
63
+ } , ) *
64
+ }
65
+ } ;
75
66
}
67
+
68
+ arm ! (
69
+ Normal ,
70
+ SetupStage ,
71
+ DataStage ,
72
+ StatusStage ,
73
+ Isoch ,
74
+ Link ,
75
+ EventData ,
76
+ Noop
77
+ )
76
78
}
77
79
}
78
80
0 commit comments