@@ -219,9 +219,10 @@ impl Field {
219219 struct #wrap_name<' a>( & ' a i32 ) ;
220220 impl <' a> :: core:: fmt:: Debug for #wrap_name<' a> {
221221 fn fmt( & self , f: & mut :: core:: fmt:: Formatter ) -> :: core:: fmt:: Result {
222- match #ty:: from_i32( * self . 0 ) {
223- None => :: core:: fmt:: Debug :: fmt( & self . 0 , f) ,
224- Some ( en) => :: core:: fmt:: Debug :: fmt( & en, f) ,
222+ let res: Result <#ty, _> = :: core:: convert:: TryFrom :: try_from( * self . 0 ) ;
223+ match res {
224+ Err ( _) => :: core:: fmt:: Debug :: fmt( & self . 0 , f) ,
225+ Ok ( en) => :: core:: fmt:: Debug :: fmt( & en, f) ,
225226 }
226227 }
227228 }
@@ -296,7 +297,7 @@ impl Field {
296297 quote ! {
297298 #[ doc=#get_doc]
298299 pub fn #get( & self ) -> #ty {
299- #ty :: from_i32 ( self . #ident) . unwrap_or( #default )
300+ :: core :: convert :: TryFrom :: try_from ( self . #ident) . unwrap_or( #default )
300301 }
301302
302303 #[ doc=#set_doc]
@@ -314,7 +315,10 @@ impl Field {
314315 quote ! {
315316 #[ doc=#get_doc]
316317 pub fn #get( & self ) -> #ty {
317- self . #ident. and_then( #ty:: from_i32) . unwrap_or( #default )
318+ self . #ident. and_then( |x| {
319+ let result: Result <#ty, _> = :: core:: convert:: TryFrom :: try_from( x) ;
320+ result. ok( )
321+ } ) . unwrap_or( #default )
318322 }
319323
320324 #[ doc=#set_doc]
@@ -336,7 +340,10 @@ impl Field {
336340 :: core:: iter:: Cloned <:: core:: slice:: Iter <i32 >>,
337341 fn ( i32 ) -> :: core:: option:: Option <#ty>,
338342 > {
339- self . #ident. iter( ) . cloned( ) . filter_map( #ty:: from_i32)
343+ self . #ident. iter( ) . cloned( ) . filter_map( |x| {
344+ let result: Result <#ty, _> = :: core:: convert:: TryFrom :: try_from( x) ;
345+ result. ok( )
346+ } )
340347 }
341348 #[ doc=#push_doc]
342349 pub fn #push( & mut self , value: #ty) {
0 commit comments