@@ -4,6 +4,7 @@ use core::marker;
44pub trait RawReg :
55 Copy
66 + Default
7+ + From < bool >
78 + core:: ops:: BitOr < Output = Self >
89 + core:: ops:: BitAnd < Output = Self >
910 + core:: ops:: BitOrAssign
@@ -268,11 +269,12 @@ impl<REG: RegisterSpec> R<REG> {
268269impl < REG : RegisterSpec , FI > PartialEq < FI > for R < REG >
269270where
270271 REG :: Ux : PartialEq ,
271- FI : Copy + Into < REG :: Ux > ,
272+ FI : Copy ,
273+ REG :: Ux : From < FI >
272274{
273275 #[ inline( always) ]
274276 fn eq ( & self , other : & FI ) -> bool {
275- self . bits . eq ( & ( * other) . into ( ) )
277+ self . bits . eq ( & REG :: Ux :: from ( * other) )
276278 }
277279}
278280
@@ -359,21 +361,23 @@ where
359361impl < U , FI > PartialEq < FI > for FieldReader < U , FI >
360362where
361363 U : PartialEq ,
362- FI : Copy + Into < U > ,
364+ FI : Copy ,
365+ U : From < FI > ,
363366{
364367 #[ inline( always) ]
365368 fn eq ( & self , other : & FI ) -> bool {
366- self . bits . eq ( & ( * other) . into ( ) )
369+ self . bits . eq ( & U :: from ( * other) )
367370 }
368371}
369372
370373impl < FI > PartialEq < FI > for BitReader < FI >
371374where
372- FI : Copy + Into < bool > ,
375+ FI : Copy ,
376+ bool : From < FI > ,
373377{
374378 #[ inline( always) ]
375379 fn eq ( & self , other : & FI ) -> bool {
376- self . bits . eq ( & ( * other) . into ( ) )
380+ self . bits . eq ( & bool :: from ( * other) )
377381 }
378382}
379383
@@ -404,7 +408,7 @@ pub struct Unsafe;
404408pub struct FieldWriterRaw < ' a , U , REG , N , FI , Safety , const WI : u8 , const O : u8 >
405409where
406410 REG : Writable + RegisterSpec < Ux = U > ,
407- FI : Into < N > ,
411+ N : From < FI > ,
408412{
409413 pub ( crate ) w : & ' a mut REG :: Writer ,
410414 _field : marker:: PhantomData < ( N , FI , Safety ) > ,
@@ -414,7 +418,7 @@ impl<'a, U, REG, N, FI, Safety, const WI: u8, const O: u8>
414418 FieldWriterRaw < ' a , U , REG , N , FI , Safety , WI , O >
415419where
416420 REG : Writable + RegisterSpec < Ux = U > ,
417- FI : Into < N > ,
421+ N : From < FI > ,
418422{
419423 /// Creates a new instance of the writer
420424 #[ allow( unused) ]
@@ -431,7 +435,7 @@ where
431435pub struct BitWriterRaw < ' a , U , REG , FI , M , const O : u8 >
432436where
433437 REG : Writable + RegisterSpec < Ux = U > ,
434- FI : Into < bool > ,
438+ bool : From < FI > ,
435439{
436440 pub ( crate ) w : & ' a mut REG :: Writer ,
437441 _field : marker:: PhantomData < ( FI , M ) > ,
@@ -440,7 +444,7 @@ where
440444impl < ' a , U , REG , FI , M , const O : u8 > BitWriterRaw < ' a , U , REG , FI , M , O >
441445where
442446 REG : Writable + RegisterSpec < Ux = U > ,
443- FI : Into < bool > ,
447+ bool : From < FI > ,
444448{
445449 /// Creates a new instance of the writer
446450 #[ allow( unused) ]
@@ -463,7 +467,7 @@ pub type FieldWriterSafe<'a, U, REG, N, FI, const WI: u8, const O: u8> =
463467impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriter < ' a , U , REG , N , FI , WI , OF >
464468where
465469 REG : Writable + RegisterSpec < Ux = U > ,
466- FI : Into < N > ,
470+ N : From < FI > ,
467471{
468472 /// Field width
469473 pub const WIDTH : u8 = WI ;
@@ -472,7 +476,7 @@ where
472476impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriterSafe < ' a , U , REG , N , FI , WI , OF >
473477where
474478 REG : Writable + RegisterSpec < Ux = U > ,
475- FI : Into < N > ,
479+ N : From < FI > ,
476480{
477481 /// Field width
478482 pub const WIDTH : u8 = WI ;
@@ -489,7 +493,7 @@ macro_rules! bit_proxy {
489493 impl <' a, U , REG , FI , const OF : u8 > $writer<' a, U , REG , FI , OF >
490494 where
491495 REG : Writable + RegisterSpec <Ux = U >,
492- FI : Into < bool >,
496+ bool : From < FI >,
493497 {
494498 /// Field width
495499 pub const WIDTH : u8 = 1 ;
@@ -503,8 +507,7 @@ macro_rules! impl_bit_proxy {
503507 where
504508 REG : Writable + RegisterSpec <Ux = U >,
505509 U : RawReg ,
506- U : From <bool >,
507- FI : Into <bool >,
510+ bool : From <FI >,
508511 {
509512 /// Writes bit to the field
510513 #[ inline( always) ]
@@ -516,7 +519,7 @@ macro_rules! impl_bit_proxy {
516519 /// Writes `variant` to the field
517520 #[ inline( always) ]
518521 pub fn variant( self , variant: FI ) -> & ' a mut REG :: Writer {
519- self . bit( variant . into ( ) )
522+ self . bit( bool :: from ( variant ) )
520523 }
521524 }
522525 } ;
@@ -533,9 +536,8 @@ bit_proxy!(BitWriter0T, Bit0T);
533536impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriter < ' a , U , REG , N , FI , WI , OF >
534537where
535538 REG : Writable + RegisterSpec < Ux = U > ,
536- U : RawReg ,
537- N : Into < U > ,
538- FI : Into < N > ,
539+ U : RawReg + From < N > ,
540+ N : From < FI > ,
539541{
540542 /// Writes raw bits to the field
541543 ///
@@ -545,33 +547,32 @@ where
545547 #[ inline( always) ]
546548 pub unsafe fn bits ( self , value : N ) -> & ' a mut REG :: Writer {
547549 self . w . bits &= !( U :: mask :: < WI > ( ) << { OF } ) ;
548- self . w . bits |= ( value . into ( ) & U :: mask :: < WI > ( ) ) << { OF } ;
550+ self . w . bits |= ( U :: from ( value ) & U :: mask :: < WI > ( ) ) << { OF } ;
549551 self . w
550552 }
551553 /// Writes `variant` to the field
552554 #[ inline( always) ]
553555 pub fn variant ( self , variant : FI ) -> & ' a mut REG :: Writer {
554- unsafe { self . bits ( variant . into ( ) ) }
556+ unsafe { self . bits ( N :: from ( variant ) ) }
555557 }
556558}
557559impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriterSafe < ' a , U , REG , N , FI , WI , OF >
558560where
559561 REG : Writable + RegisterSpec < Ux = U > ,
560- U : RawReg ,
561- N : Into < U > ,
562- FI : Into < N > ,
562+ U : RawReg + From < N > ,
563+ N : From < FI > ,
563564{
564565 /// Writes raw bits to the field
565566 #[ inline( always) ]
566567 pub fn bits ( self , value : N ) -> & ' a mut REG :: Writer {
567568 self . w . bits &= !( U :: mask :: < WI > ( ) << { OF } ) ;
568- self . w . bits |= ( value . into ( ) & U :: mask :: < WI > ( ) ) << { OF } ;
569+ self . w . bits |= ( U :: from ( value ) & U :: mask :: < WI > ( ) ) << { OF } ;
569570 self . w
570571 }
571572 /// Writes `variant` to the field
572573 #[ inline( always) ]
573574 pub fn variant ( self , variant : FI ) -> & ' a mut REG :: Writer {
574- self . bits ( variant . into ( ) )
575+ self . bits ( N :: from ( variant ) )
575576 }
576577}
577578
@@ -587,8 +588,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter<'a, U, REG, FI, OF>
587588where
588589 REG : Writable + RegisterSpec < Ux = U > ,
589590 U : RawReg ,
590- U : From < bool > ,
591- FI : Into < bool > ,
591+ bool : From < FI > ,
592592{
593593 /// Sets the field bit
594594 #[ inline( always) ]
@@ -606,8 +606,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter1S<'a, U, REG, FI, OF>
606606where
607607 REG : Writable + RegisterSpec < Ux = U > ,
608608 U : RawReg ,
609- U : From < bool > ,
610- FI : Into < bool > ,
609+ bool : From < FI > ,
611610{
612611 /// Sets the field bit
613612 #[ inline( always) ]
@@ -620,8 +619,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter0C<'a, U, REG, FI, OF>
620619where
621620 REG : Writable + RegisterSpec < Ux = U > ,
622621 U : RawReg ,
623- U : From < bool > ,
624- FI : Into < bool > ,
622+ bool : From < FI > ,
625623{
626624 /// Clears the field bit
627625 #[ inline( always) ]
@@ -634,8 +632,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter1C<'a, U, REG, FI, OF>
634632where
635633 REG : Writable + RegisterSpec < Ux = U > ,
636634 U : RawReg ,
637- U : From < bool > ,
638- FI : Into < bool > ,
635+ bool : From < FI > ,
639636{
640637 ///Clears the field bit by passing one
641638 #[ inline( always) ]
@@ -648,8 +645,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter0S<'a, U, REG, FI, OF>
648645where
649646 REG : Writable + RegisterSpec < Ux = U > ,
650647 U : RawReg ,
651- U : From < bool > ,
652- FI : Into < bool > ,
648+ bool : From < FI > ,
653649{
654650 ///Sets the field bit by passing zero
655651 #[ inline( always) ]
@@ -662,8 +658,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter1T<'a, U, REG, FI, OF>
662658where
663659 REG : Writable + RegisterSpec < Ux = U > ,
664660 U : RawReg ,
665- U : From < bool > ,
666- FI : Into < bool > ,
661+ bool : From < FI > ,
667662{
668663 ///Toggle the field bit by passing one
669664 #[ inline( always) ]
@@ -676,8 +671,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter0T<'a, U, REG, FI, OF>
676671where
677672 REG : Writable + RegisterSpec < Ux = U > ,
678673 U : RawReg ,
679- U : From < bool > ,
680- FI : Into < bool > ,
674+ bool : From < FI > ,
681675{
682676 ///Toggle the field bit by passing zero
683677 #[ inline( always) ]
0 commit comments