@@ -58,58 +58,78 @@ pub fn render(
5858
5959 if can_read {
6060 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+ } ;
6166 mod_items. extend ( quote ! {
6267 #[ doc = #desc]
68+ #derive
6369 pub struct R ( crate :: R <#name_uc_spec>) ;
70+ } ) ;
6471
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>;
6776
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+ }
7181 }
72- }
7382
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+ }
7888 }
79- }
80- } ) ;
89+ } ) ;
90+ }
8191 methods. push ( "read" ) ;
8292 }
8393
8494 if can_write {
8595 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+ } ;
86101 mod_items. extend ( quote ! {
87102 #[ doc = #desc]
103+ #derive
88104 pub struct W ( crate :: W <#name_uc_spec>) ;
105+ } ) ;
89106
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>;
92111
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+ }
96116 }
97- }
98117
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+ }
103123 }
104- }
105124
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+ }
110130 }
111- }
112- } ) ;
131+ } ) ;
132+ }
113133 methods. push ( "write_with_zero" ) ;
114134 if can_reset {
115135 methods. push ( "reset" ) ;
0 commit comments