@@ -58,58 +58,78 @@ pub fn render(
58
58
59
59
if can_read {
60
60
let desc = format ! ( "Register `{}` reader" , register. name) ;
61
+ let derive = if config. derive_more {
62
+ Some ( quote ! { #[ derive( derive_more:: Deref , derive_more:: From ) ] } )
63
+ } else {
64
+ None
65
+ } ;
61
66
mod_items. extend ( quote ! {
62
67
#[ doc = #desc]
68
+ #derive
63
69
pub struct R ( crate :: R <#name_uc_spec>) ;
70
+ } ) ;
64
71
65
- impl core:: ops:: Deref for R {
66
- type Target = crate :: R <#name_uc_spec>;
72
+ if !config. derive_more {
73
+ mod_items. extend ( quote ! {
74
+ impl core:: ops:: Deref for R {
75
+ type Target = crate :: R <#name_uc_spec>;
67
76
68
- #[ inline( always) ]
69
- fn deref( & self ) -> & Self :: Target {
70
- & self . 0
77
+ #[ inline( always) ]
78
+ fn deref( & self ) -> & Self :: Target {
79
+ & self . 0
80
+ }
71
81
}
72
- }
73
82
74
- impl From <crate :: R <#name_uc_spec>> for R {
75
- #[ inline( always) ]
76
- fn from( reader: crate :: R <#name_uc_spec>) -> Self {
77
- R ( reader)
83
+ impl From <crate :: R <#name_uc_spec>> for R {
84
+ #[ inline( always) ]
85
+ fn from( reader: crate :: R <#name_uc_spec>) -> Self {
86
+ R ( reader)
87
+ }
78
88
}
79
- }
80
- } ) ;
89
+ } ) ;
90
+ }
81
91
methods. push ( "read" ) ;
82
92
}
83
93
84
94
if can_write {
85
95
let desc = format ! ( "Register `{}` writer" , register. name) ;
96
+ let derive = if config. derive_more {
97
+ Some ( quote ! { #[ derive( derive_more:: Deref , derive_more:: DerefMut , derive_more:: From ) ] } )
98
+ } else {
99
+ None
100
+ } ;
86
101
mod_items. extend ( quote ! {
87
102
#[ doc = #desc]
103
+ #derive
88
104
pub struct W ( crate :: W <#name_uc_spec>) ;
105
+ } ) ;
89
106
90
- impl core:: ops:: Deref for W {
91
- type Target = crate :: W <#name_uc_spec>;
107
+ if !config. derive_more {
108
+ mod_items. extend ( quote ! {
109
+ impl core:: ops:: Deref for W {
110
+ type Target = crate :: W <#name_uc_spec>;
92
111
93
- #[ inline( always) ]
94
- fn deref( & self ) -> & Self :: Target {
95
- & self . 0
112
+ #[ inline( always) ]
113
+ fn deref( & self ) -> & Self :: Target {
114
+ & self . 0
115
+ }
96
116
}
97
- }
98
117
99
- impl core:: ops:: DerefMut for W {
100
- #[ inline( always) ]
101
- fn deref_mut( & mut self ) -> & mut Self :: Target {
102
- & mut self . 0
118
+ impl core:: ops:: DerefMut for W {
119
+ #[ inline( always) ]
120
+ fn deref_mut( & mut self ) -> & mut Self :: Target {
121
+ & mut self . 0
122
+ }
103
123
}
104
- }
105
124
106
- impl From <crate :: W <#name_uc_spec>> for W {
107
- #[ inline( always) ]
108
- fn from( writer: crate :: W <#name_uc_spec>) -> Self {
109
- W ( writer)
125
+ impl From <crate :: W <#name_uc_spec>> for W {
126
+ #[ inline( always) ]
127
+ fn from( writer: crate :: W <#name_uc_spec>) -> Self {
128
+ W ( writer)
129
+ }
110
130
}
111
- }
112
- } ) ;
131
+ } ) ;
132
+ }
113
133
methods. push ( "write_with_zero" ) ;
114
134
if can_reset {
115
135
methods. push ( "reset" ) ;
0 commit comments