@@ -365,6 +365,140 @@ macro_rules! impl_size_type_comparisons_for_row_ids {
365365 } ;
366366}
367367
368+ macro_rules! impl_f64_newtypes {
369+ ( $type: ty) => {
370+ impl std:: fmt:: Display for $type {
371+ fn fmt( & self , f: & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
372+ write!( f, "{}({})" , stringify!( $idtype) , self . 0 )
373+ }
374+ }
375+
376+ impl PartialEq <f64 > for $type {
377+ fn eq( & self , other: & f64 ) -> bool {
378+ self . 0 . eq( other)
379+ }
380+ }
381+
382+ impl PartialEq <$type> for f64 {
383+ fn eq( & self , other: & $type) -> bool {
384+ self . eq( & other. 0 )
385+ }
386+ }
387+
388+ impl PartialOrd <f64 > for $type {
389+ fn partial_cmp( & self , other: & f64 ) -> Option <std:: cmp:: Ordering > {
390+ self . 0 . partial_cmp( other)
391+ }
392+ }
393+
394+ impl PartialOrd <$type> for f64 {
395+ fn partial_cmp( & self , other: & $type) -> Option <std:: cmp:: Ordering > {
396+ self . partial_cmp( & other. 0 )
397+ }
398+ }
399+
400+ impl From <f64 > for $type {
401+ fn from( value: f64 ) -> Self {
402+ Self ( value)
403+ }
404+ }
405+
406+ impl From <$type> for f64 {
407+ fn from( value: $type) -> Self {
408+ value. 0
409+ }
410+ }
411+
412+ impl std:: ops:: Sub for $type {
413+ type Output = Self ;
414+
415+ fn sub( self , rhs: Self ) -> Self :: Output {
416+ Self ( self . 0 - rhs. 0 )
417+ }
418+ }
419+
420+ impl std:: ops:: SubAssign for $type {
421+ fn sub_assign( & mut self , rhs: Self ) {
422+ self . 0 -= rhs. 0
423+ }
424+ }
425+
426+ impl std:: ops:: Add for $type {
427+ type Output = Self ;
428+
429+ fn add( self , rhs: Self ) -> Self :: Output {
430+ Self ( self . 0 + rhs. 0 )
431+ }
432+ }
433+
434+ impl std:: ops:: AddAssign for $type {
435+ fn add_assign( & mut self , rhs: Self ) {
436+ self . 0 += rhs. 0
437+ }
438+ }
439+
440+ impl std:: ops:: Mul for $type {
441+ type Output = Self ;
442+
443+ fn mul( self , rhs: Self ) -> Self :: Output {
444+ Self ( self . 0 * rhs. 0 )
445+ }
446+ }
447+
448+ impl std:: ops:: MulAssign for $type {
449+ fn mul_assign( & mut self , rhs: Self ) {
450+ self . 0 . mul_assign( & rhs. 0 )
451+ }
452+ }
453+
454+ impl std:: ops:: Div for $type {
455+ type Output = Self ;
456+
457+ fn div( self , rhs: Self ) -> Self :: Output {
458+ Self ( self . 0 / rhs. 0 )
459+ }
460+ }
461+
462+ impl std:: ops:: DivAssign for $type {
463+ fn div_assign( & mut self , rhs: Self ) {
464+ self . 0 . div_assign( & rhs. 0 )
465+ }
466+ }
467+ } ;
468+ }
469+
470+ macro_rules! impl_time_position_arithmetic {
471+ ( $lhs: ty, $rhs: ty) => {
472+ impl std:: ops:: Mul <$rhs> for $lhs {
473+ type Output = $lhs;
474+
475+ fn mul( self , other: $rhs) -> Self {
476+ Self ( self . 0 . mul( & other. 0 ) )
477+ }
478+ }
479+
480+ impl std:: ops:: MulAssign <$rhs> for $lhs {
481+ fn mul_assign( & mut self , other: $rhs) {
482+ self . 0 . mul_assign( & other. 0 )
483+ }
484+ }
485+
486+ impl std:: ops:: Div <$rhs> for $lhs {
487+ type Output = $lhs;
488+
489+ fn div( self , other: $rhs) -> Self {
490+ Self ( self . 0 . div( & other. 0 ) )
491+ }
492+ }
493+
494+ impl std:: ops:: DivAssign <$rhs> for $lhs {
495+ fn div_assign( & mut self , other: $rhs) {
496+ self . 0 . div_assign( & other. 0 )
497+ }
498+ }
499+ } ;
500+ }
501+
368502/// Convenience macro to handle implementing
369503/// [`crate::metadata::MetadataRoundtrip`]
370504#[ macro_export]
0 commit comments