File tree Expand file tree Collapse file tree 3 files changed +15
-15
lines changed
Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -84,32 +84,32 @@ pub fn is_integer(v: f64) -> bool {
8484}
8585
8686#[ derive( Debug ) ]
87- pub enum FloatFormatCase {
87+ pub enum Case {
8888 Lower ,
8989 Upper ,
9090}
9191
92- fn format_nan ( case : FloatFormatCase ) -> String {
92+ fn format_nan ( case : Case ) -> String {
9393 let nan = match case {
94- FloatFormatCase :: Lower => "nan" ,
95- FloatFormatCase :: Upper => "NAN" ,
94+ Case :: Lower => "nan" ,
95+ Case :: Upper => "NAN" ,
9696 } ;
9797
9898 nan. to_string ( )
9999}
100100
101- fn format_inf ( case : FloatFormatCase ) -> String {
101+ fn format_inf ( case : Case ) -> String {
102102 let inf = match case {
103- FloatFormatCase :: Lower => "inf" ,
104- FloatFormatCase :: Upper => "INF" ,
103+ Case :: Lower => "inf" ,
104+ Case :: Upper => "INF" ,
105105 } ;
106106
107107 inf. to_string ( )
108108}
109109
110110// Formats floats into Python style exponent notation, by first formatting in Rust style
111111// exponent notation (`1.0000e0`), then convert to Python style (`1.0000e+00`).
112- pub fn format_float_as_exponent ( precision : usize , magnitude : f64 , case : FloatFormatCase ) -> String {
112+ pub fn format_exponent ( precision : usize , magnitude : f64 , case : Case ) -> String {
113113 match magnitude {
114114 magnitude if magnitude. is_finite ( ) => {
115115 let r_exp = format ! ( "{:.*e}" , precision, magnitude) ;
Original file line number Diff line number Diff line change @@ -329,11 +329,11 @@ impl CFormatSpec {
329329 }
330330 CFormatType :: Float ( CFloatType :: Exponent ( case) ) => {
331331 let case = match case {
332- CFormatCase :: Lowercase => float_ops:: FloatFormatCase :: Lower ,
333- CFormatCase :: Uppercase => float_ops:: FloatFormatCase :: Upper ,
332+ CFormatCase :: Lowercase => float_ops:: Case :: Lower ,
333+ CFormatCase :: Uppercase => float_ops:: Case :: Upper ,
334334 } ;
335335 let magnitude = num. abs ( ) ;
336- float_ops:: format_float_as_exponent ( precision, magnitude, case)
336+ float_ops:: format_exponent ( precision, magnitude, case)
337337 }
338338 CFormatType :: Float ( CFloatType :: General ( case) ) => {
339339 let precision = if precision == 0 { 1 } else { precision } ;
Original file line number Diff line number Diff line change @@ -375,15 +375,15 @@ impl FormatSpec {
375375 Some ( FormatType :: GeneralFormatLower ) => {
376376 Err ( "Format code 'g' for object of type 'float' not implemented yet" )
377377 }
378- Some ( FormatType :: ExponentUpper ) => Ok ( float_ops:: format_float_as_exponent (
378+ Some ( FormatType :: ExponentUpper ) => Ok ( float_ops:: format_exponent (
379379 precision,
380380 magnitude,
381- float_ops:: FloatFormatCase :: Upper ,
381+ float_ops:: Case :: Upper ,
382382 ) ) ,
383- Some ( FormatType :: ExponentLower ) => Ok ( float_ops:: format_float_as_exponent (
383+ Some ( FormatType :: ExponentLower ) => Ok ( float_ops:: format_exponent (
384384 precision,
385385 magnitude,
386- float_ops:: FloatFormatCase :: Lower ,
386+ float_ops:: Case :: Lower ,
387387 ) ) ,
388388 Some ( FormatType :: Percentage ) => match magnitude {
389389 magnitude if magnitude. is_nan ( ) => Ok ( "nan%" . to_owned ( ) ) ,
You can’t perform that action at this time.
0 commit comments