@@ -512,43 +512,39 @@ pub fn num_ops(input: TokenStream) -> TokenStream {
512
512
let ast: syn:: DeriveInput = syn:: parse ( input) . unwrap ( ) ;
513
513
let name = & ast. ident ;
514
514
let inner_ty = newtype_inner ( & ast. data ) . expect ( NEWTYPE_ONLY ) ;
515
- dummy_const_trick (
516
- "NumOps" ,
517
- & name,
518
- quote ! {
519
- impl :: std:: ops:: Add for #name {
520
- type Output = Self ;
521
- fn add( self , other: Self ) -> Self {
522
- #name( <#inner_ty as :: std:: ops:: Add >:: add( self . 0 , other. 0 ) )
523
- }
515
+ let impl_ = quote ! {
516
+ impl :: std:: ops:: Add for #name {
517
+ type Output = Self ;
518
+ fn add( self , other: Self ) -> Self {
519
+ #name( <#inner_ty as :: std:: ops:: Add >:: add( self . 0 , other. 0 ) )
524
520
}
525
- impl :: std :: ops :: Sub for #name {
526
- type Output = Self ;
527
- fn sub ( self , other : Self ) -> Self {
528
- #name ( <#inner_ty as :: std :: ops :: Sub > :: sub( self . 0 , other. 0 ) )
529
- }
521
+ }
522
+ impl :: std :: ops :: Sub for #name {
523
+ type Output = Self ;
524
+ fn sub( self , other: Self ) -> Self {
525
+ #name ( <#inner_ty as :: std :: ops :: Sub > :: sub ( self . 0 , other . 0 ) )
530
526
}
531
- impl :: std :: ops :: Mul for #name {
532
- type Output = Self ;
533
- fn mul ( self , other : Self ) -> Self {
534
- #name ( <#inner_ty as :: std :: ops :: Mul > :: mul( self . 0 , other. 0 ) )
535
- }
527
+ }
528
+ impl :: std :: ops :: Mul for #name {
529
+ type Output = Self ;
530
+ fn mul( self , other: Self ) -> Self {
531
+ #name ( <#inner_ty as :: std :: ops :: Mul > :: mul ( self . 0 , other . 0 ) )
536
532
}
537
- impl :: std :: ops :: Div for #name {
538
- type Output = Self ;
539
- fn div ( self , other : Self ) -> Self {
540
- #name ( <#inner_ty as :: std :: ops :: Div > :: div( self . 0 , other. 0 ) )
541
- }
533
+ }
534
+ impl :: std :: ops :: Div for #name {
535
+ type Output = Self ;
536
+ fn div( self , other: Self ) -> Self {
537
+ #name ( <#inner_ty as :: std :: ops :: Div > :: div ( self . 0 , other . 0 ) )
542
538
}
543
- impl :: std :: ops :: Rem for #name {
544
- type Output = Self ;
545
- fn rem ( self , other : Self ) -> Self {
546
- #name ( <#inner_ty as :: std :: ops :: Rem > :: rem( self . 0 , other. 0 ) )
547
- }
539
+ }
540
+ impl :: std :: ops :: Rem for #name {
541
+ type Output = Self ;
542
+ fn rem( self , other: Self ) -> Self {
543
+ #name ( <#inner_ty as :: std :: ops :: Rem > :: rem ( self . 0 , other . 0 ) )
548
544
}
549
- } ,
550
- )
551
- . into ( )
545
+ }
546
+ } ;
547
+ impl_ . into ( )
552
548
}
553
549
554
550
/// Derives [`num_traits::NumCast`][num_cast] for newtypes. The inner type must already implement
0 commit comments