@@ -28,10 +28,10 @@ impl Item {
2828 match self {
2929 Item :: TopLevel ( crate_name) => crate_name. clone ( ) ,
3030 Item :: CrateLevel ( config_option) => {
31- let display_value = format_using_display_hint (
32- & config_option . actual_value ,
33- & config_option . option . display_hint ,
34- ) ;
31+ let display_value = config_option
32+ . option
33+ . display_hint
34+ . format_value ( & config_option . actual_value ) ;
3535 let default_indicator =
3636 if config_option. actual_value == config_option. option . default_value {
3737 ui_elements. default_value
@@ -81,24 +81,11 @@ impl Item {
8181 fn display_hint ( & self ) -> DisplayHint {
8282 match self {
8383 Item :: TopLevel ( _) => unreachable ! ( ) ,
84- Item :: CrateLevel ( config_option) => config_option. option . display_hint . clone ( ) ,
84+ Item :: CrateLevel ( config_option) => config_option. option . display_hint ,
8585 }
8686 }
8787}
8888
89- fn format_using_display_hint ( value : & Value , hint : & DisplayHint ) -> String {
90- match value {
91- Value :: Bool ( b) => b. to_string ( ) ,
92- Value :: Integer ( i) => match hint {
93- DisplayHint :: None => format ! ( "{}" , i) ,
94- DisplayHint :: Binary => format ! ( "0b{:0b}" , i) ,
95- DisplayHint :: Hex => format ! ( "0x{:x}" , i) ,
96- DisplayHint :: Octal => format ! ( "0o{:o}" , i) ,
97- } ,
98- Value :: String ( s) => s. clone ( ) ,
99- }
100- }
101-
10289impl Repository {
10390 pub fn new ( options : Vec < crate :: CrateConfig > ) -> Self {
10491 Self {
@@ -474,11 +461,10 @@ impl App<'_> {
474461 self . handle_error ( set_res) ;
475462 }
476463 Value :: Integer ( _) => {
477- let display_value = format_using_display_hint (
478- & current,
479- & self . repository . current_level ( ) [ selected]
480- . display_hint ( ) ,
481- ) ;
464+ let display_value = self . repository . current_level ( )
465+ [ selected]
466+ . display_hint ( )
467+ . format_value ( & current) ;
482468 self . textarea =
483469 make_text_area ( & display_value, & self . colors ) ;
484470 self . editing_constraints = constraint;
0 commit comments