@@ -4,6 +4,7 @@ use core::marker;
4
4
pub trait RawReg :
5
5
Copy
6
6
+ Default
7
+ + From < bool >
7
8
+ core:: ops:: BitOr < Output = Self >
8
9
+ core:: ops:: BitAnd < Output = Self >
9
10
+ core:: ops:: BitOrAssign
@@ -268,11 +269,12 @@ impl<REG: RegisterSpec> R<REG> {
268
269
impl < REG : RegisterSpec , FI > PartialEq < FI > for R < REG >
269
270
where
270
271
REG :: Ux : PartialEq ,
271
- FI : Copy + Into < REG :: Ux > ,
272
+ FI : Copy ,
273
+ REG :: Ux : From < FI >
272
274
{
273
275
#[ inline( always) ]
274
276
fn eq ( & self , other : & FI ) -> bool {
275
- self . bits . eq ( & ( * other) . into ( ) )
277
+ self . bits . eq ( & REG :: Ux :: from ( * other) )
276
278
}
277
279
}
278
280
@@ -359,21 +361,23 @@ where
359
361
impl < U , FI > PartialEq < FI > for FieldReader < U , FI >
360
362
where
361
363
U : PartialEq ,
362
- FI : Copy + Into < U > ,
364
+ FI : Copy ,
365
+ U : From < FI > ,
363
366
{
364
367
#[ inline( always) ]
365
368
fn eq ( & self , other : & FI ) -> bool {
366
- self . bits . eq ( & ( * other) . into ( ) )
369
+ self . bits . eq ( & U :: from ( * other) )
367
370
}
368
371
}
369
372
370
373
impl < FI > PartialEq < FI > for BitReader < FI >
371
374
where
372
- FI : Copy + Into < bool > ,
375
+ FI : Copy ,
376
+ bool : From < FI > ,
373
377
{
374
378
#[ inline( always) ]
375
379
fn eq ( & self , other : & FI ) -> bool {
376
- self . bits . eq ( & ( * other) . into ( ) )
380
+ self . bits . eq ( & bool :: from ( * other) )
377
381
}
378
382
}
379
383
@@ -404,7 +408,7 @@ pub struct Unsafe;
404
408
pub struct FieldWriterRaw < ' a , U , REG , N , FI , Safety , const WI : u8 , const O : u8 >
405
409
where
406
410
REG : Writable + RegisterSpec < Ux = U > ,
407
- FI : Into < N > ,
411
+ N : From < FI > ,
408
412
{
409
413
pub ( crate ) w : & ' a mut REG :: Writer ,
410
414
_field : marker:: PhantomData < ( N , FI , Safety ) > ,
@@ -414,7 +418,7 @@ impl<'a, U, REG, N, FI, Safety, const WI: u8, const O: u8>
414
418
FieldWriterRaw < ' a , U , REG , N , FI , Safety , WI , O >
415
419
where
416
420
REG : Writable + RegisterSpec < Ux = U > ,
417
- FI : Into < N > ,
421
+ N : From < FI > ,
418
422
{
419
423
/// Creates a new instance of the writer
420
424
#[ allow( unused) ]
@@ -431,7 +435,7 @@ where
431
435
pub struct BitWriterRaw < ' a , U , REG , FI , M , const O : u8 >
432
436
where
433
437
REG : Writable + RegisterSpec < Ux = U > ,
434
- FI : Into < bool > ,
438
+ bool : From < FI > ,
435
439
{
436
440
pub ( crate ) w : & ' a mut REG :: Writer ,
437
441
_field : marker:: PhantomData < ( FI , M ) > ,
@@ -440,7 +444,7 @@ where
440
444
impl < ' a , U , REG , FI , M , const O : u8 > BitWriterRaw < ' a , U , REG , FI , M , O >
441
445
where
442
446
REG : Writable + RegisterSpec < Ux = U > ,
443
- FI : Into < bool > ,
447
+ bool : From < FI > ,
444
448
{
445
449
/// Creates a new instance of the writer
446
450
#[ allow( unused) ]
@@ -463,7 +467,7 @@ pub type FieldWriterSafe<'a, U, REG, N, FI, const WI: u8, const O: u8> =
463
467
impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriter < ' a , U , REG , N , FI , WI , OF >
464
468
where
465
469
REG : Writable + RegisterSpec < Ux = U > ,
466
- FI : Into < N > ,
470
+ N : From < FI > ,
467
471
{
468
472
/// Field width
469
473
pub const WIDTH : u8 = WI ;
@@ -472,7 +476,7 @@ where
472
476
impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriterSafe < ' a , U , REG , N , FI , WI , OF >
473
477
where
474
478
REG : Writable + RegisterSpec < Ux = U > ,
475
- FI : Into < N > ,
479
+ N : From < FI > ,
476
480
{
477
481
/// Field width
478
482
pub const WIDTH : u8 = WI ;
@@ -489,7 +493,7 @@ macro_rules! bit_proxy {
489
493
impl <' a, U , REG , FI , const OF : u8 > $writer<' a, U , REG , FI , OF >
490
494
where
491
495
REG : Writable + RegisterSpec <Ux = U >,
492
- FI : Into < bool >,
496
+ bool : From < FI >,
493
497
{
494
498
/// Field width
495
499
pub const WIDTH : u8 = 1 ;
@@ -503,8 +507,7 @@ macro_rules! impl_bit_proxy {
503
507
where
504
508
REG : Writable + RegisterSpec <Ux = U >,
505
509
U : RawReg ,
506
- U : From <bool >,
507
- FI : Into <bool >,
510
+ bool : From <FI >,
508
511
{
509
512
/// Writes bit to the field
510
513
#[ inline( always) ]
@@ -516,7 +519,7 @@ macro_rules! impl_bit_proxy {
516
519
/// Writes `variant` to the field
517
520
#[ inline( always) ]
518
521
pub fn variant( self , variant: FI ) -> & ' a mut REG :: Writer {
519
- self . bit( variant . into ( ) )
522
+ self . bit( bool :: from ( variant ) )
520
523
}
521
524
}
522
525
} ;
@@ -533,9 +536,8 @@ bit_proxy!(BitWriter0T, Bit0T);
533
536
impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriter < ' a , U , REG , N , FI , WI , OF >
534
537
where
535
538
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 > ,
539
541
{
540
542
/// Writes raw bits to the field
541
543
///
@@ -545,33 +547,32 @@ where
545
547
#[ inline( always) ]
546
548
pub unsafe fn bits ( self , value : N ) -> & ' a mut REG :: Writer {
547
549
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 } ;
549
551
self . w
550
552
}
551
553
/// Writes `variant` to the field
552
554
#[ inline( always) ]
553
555
pub fn variant ( self , variant : FI ) -> & ' a mut REG :: Writer {
554
- unsafe { self . bits ( variant . into ( ) ) }
556
+ unsafe { self . bits ( N :: from ( variant ) ) }
555
557
}
556
558
}
557
559
impl < ' a , U , REG , N , FI , const WI : u8 , const OF : u8 > FieldWriterSafe < ' a , U , REG , N , FI , WI , OF >
558
560
where
559
561
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 > ,
563
564
{
564
565
/// Writes raw bits to the field
565
566
#[ inline( always) ]
566
567
pub fn bits ( self , value : N ) -> & ' a mut REG :: Writer {
567
568
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 } ;
569
570
self . w
570
571
}
571
572
/// Writes `variant` to the field
572
573
#[ inline( always) ]
573
574
pub fn variant ( self , variant : FI ) -> & ' a mut REG :: Writer {
574
- self . bits ( variant . into ( ) )
575
+ self . bits ( N :: from ( variant ) )
575
576
}
576
577
}
577
578
@@ -587,8 +588,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter<'a, U, REG, FI, OF>
587
588
where
588
589
REG : Writable + RegisterSpec < Ux = U > ,
589
590
U : RawReg ,
590
- U : From < bool > ,
591
- FI : Into < bool > ,
591
+ bool : From < FI > ,
592
592
{
593
593
/// Sets the field bit
594
594
#[ inline( always) ]
@@ -606,8 +606,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter1S<'a, U, REG, FI, OF>
606
606
where
607
607
REG : Writable + RegisterSpec < Ux = U > ,
608
608
U : RawReg ,
609
- U : From < bool > ,
610
- FI : Into < bool > ,
609
+ bool : From < FI > ,
611
610
{
612
611
/// Sets the field bit
613
612
#[ inline( always) ]
@@ -620,8 +619,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter0C<'a, U, REG, FI, OF>
620
619
where
621
620
REG : Writable + RegisterSpec < Ux = U > ,
622
621
U : RawReg ,
623
- U : From < bool > ,
624
- FI : Into < bool > ,
622
+ bool : From < FI > ,
625
623
{
626
624
/// Clears the field bit
627
625
#[ inline( always) ]
@@ -634,8 +632,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter1C<'a, U, REG, FI, OF>
634
632
where
635
633
REG : Writable + RegisterSpec < Ux = U > ,
636
634
U : RawReg ,
637
- U : From < bool > ,
638
- FI : Into < bool > ,
635
+ bool : From < FI > ,
639
636
{
640
637
///Clears the field bit by passing one
641
638
#[ inline( always) ]
@@ -648,8 +645,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter0S<'a, U, REG, FI, OF>
648
645
where
649
646
REG : Writable + RegisterSpec < Ux = U > ,
650
647
U : RawReg ,
651
- U : From < bool > ,
652
- FI : Into < bool > ,
648
+ bool : From < FI > ,
653
649
{
654
650
///Sets the field bit by passing zero
655
651
#[ inline( always) ]
@@ -662,8 +658,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter1T<'a, U, REG, FI, OF>
662
658
where
663
659
REG : Writable + RegisterSpec < Ux = U > ,
664
660
U : RawReg ,
665
- U : From < bool > ,
666
- FI : Into < bool > ,
661
+ bool : From < FI > ,
667
662
{
668
663
///Toggle the field bit by passing one
669
664
#[ inline( always) ]
@@ -676,8 +671,7 @@ impl<'a, U, REG, FI, const OF: u8> BitWriter0T<'a, U, REG, FI, OF>
676
671
where
677
672
REG : Writable + RegisterSpec < Ux = U > ,
678
673
U : RawReg ,
679
- U : From < bool > ,
680
- FI : Into < bool > ,
674
+ bool : From < FI > ,
681
675
{
682
676
///Toggle the field bit by passing zero
683
677
#[ inline( always) ]
0 commit comments