@@ -2,7 +2,8 @@ use std::convert::TryFrom;
22use std:: ops:: Range ;
33
44use crate :: coord:: ranged1d:: {
5- AsRangedCoord , DefaultFormatting , DiscreteRanged , KeyPointHint , Ranged , ReversibleRanged ,
5+ AsRangedCoord , DefaultFormatting , DiscreteRanged , KeyPointHint , NoDefaultFormatting , Ranged ,
6+ ReversibleRanged , ValueFormatter ,
67} ;
78
89macro_rules! impl_discrete_trait {
@@ -58,7 +59,7 @@ macro_rules! impl_reverse_mapping_trait {
5859 } ;
5960}
6061macro_rules! make_numeric_coord {
61- ( $type: ty, $name: ident, $key_points: ident, $doc: expr) => {
62+ ( $type: ty, $name: ident, $key_points: ident, $doc: expr, $fmt : ident ) => {
6263 #[ doc = $doc]
6364 #[ derive( Clone ) ]
6465 pub struct $name( $type, $type) ;
@@ -68,7 +69,7 @@ macro_rules! make_numeric_coord {
6869 }
6970 }
7071 impl Ranged for $name {
71- type FormatOption = DefaultFormatting ;
72+ type FormatOption = $fmt ;
7273 type ValueType = $type;
7374 #[ allow( clippy:: float_cmp) ]
7475 fn map( & self , v: & $type, limit: ( i32 , i32 ) ) -> i32 {
@@ -96,6 +97,9 @@ macro_rules! make_numeric_coord {
9697 }
9798 }
9899 } ;
100+ ( $type: ty, $name: ident, $key_points: ident, $doc: expr) => {
101+ make_numeric_coord!( $type, $name, $key_points, $doc, DefaultFormatting ) ;
102+ }
99103}
100104
101105macro_rules! gen_key_points_comp {
@@ -207,16 +211,28 @@ make_numeric_coord!(
207211 f32 ,
208212 RangedCoordf32 ,
209213 compute_f32_key_points,
210- "The ranged coordinate for type f32"
214+ "The ranged coordinate for type f32" ,
215+ NoDefaultFormatting
211216) ;
212217impl_reverse_mapping_trait ! ( f32 , RangedCoordf32 ) ;
218+ impl ValueFormatter < f32 > for RangedCoordf32 {
219+ fn format ( value : & f32 ) -> String {
220+ crate :: data:: float:: pretty_print_float ( * value as f64 , false )
221+ }
222+ }
213223make_numeric_coord ! (
214224 f64 ,
215225 RangedCoordf64 ,
216226 compute_f64_key_points,
217- "The ranged coordinate for type f64"
227+ "The ranged coordinate for type f64" ,
228+ NoDefaultFormatting
218229) ;
219230impl_reverse_mapping_trait ! ( f64 , RangedCoordf64 ) ;
231+ impl ValueFormatter < f64 > for RangedCoordf64 {
232+ fn format ( value : & f64 ) -> String {
233+ crate :: data:: float:: pretty_print_float ( * value, false )
234+ }
235+ }
220236make_numeric_coord ! (
221237 u32 ,
222238 RangedCoordu32 ,
0 commit comments