File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -482,11 +482,19 @@ impl fmt::Display for DerivationPath {
482482 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
483483 let mut iter = self . 0 . iter ( ) ;
484484 if let Some ( first_element) = iter. next ( ) {
485- write ! ( f, "{}" , first_element) ?;
485+ if f. alternate ( ) {
486+ write ! ( f, "{:#}" , first_element) ?;
487+ } else {
488+ write ! ( f, "{}" , first_element) ?;
489+ }
486490 }
487491 for cn in iter {
488492 f. write_str ( "/" ) ?;
489- write ! ( f, "{}" , cn) ?;
493+ if f. alternate ( ) {
494+ write ! ( f, "{:#}" , cn) ?;
495+ } else {
496+ write ! ( f, "{}" , cn) ?;
497+ }
490498 }
491499 Ok ( ( ) )
492500 }
@@ -1108,6 +1116,13 @@ mod tests {
11081116 }
11091117 }
11101118
1119+ #[ test]
1120+ fn test_derivation_path_display ( ) {
1121+ let path = DerivationPath :: from_str ( "m/84'/0'/0'/0/0" ) . unwrap ( ) ;
1122+ assert_eq ! ( format!( "{}" , path) , "84'/0'/0'/0/0" ) ;
1123+ assert_eq ! ( format!( "{:#}" , path) , "84h/0h/0h/0/0" ) ;
1124+ }
1125+
11111126 #[ test]
11121127 fn parse_derivation_path_out_of_range ( ) {
11131128 let invalid_path = "2147483648" ;
You can’t perform that action at this time.
0 commit comments