@@ -762,15 +762,15 @@ mod tests {
762762
763763 // Find direct children in dir_trees (paths whose parent == "a")
764764 for ( child_path, child_tree) in & dir_trees {
765- if let Some ( parent) = child_path. parent ( ) {
766- if parent == dir_path {
767- let child_name = child_path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
768- items . push ( TreeItem {
769- mode : TreeItemMode :: Tree ,
770- id : child_tree . id ,
771- name : child_name . to_string ( ) ,
772- } ) ;
773- }
765+ if let Some ( parent) = child_path. parent ( )
766+ && parent == dir_path
767+ {
768+ let child_name = child_path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
769+ items . push ( TreeItem {
770+ mode : TreeItemMode :: Tree ,
771+ id : child_tree . id ,
772+ name : child_name . to_string ( ) ,
773+ } ) ;
774774 }
775775 }
776776
@@ -803,15 +803,15 @@ mod tests {
803803
804804 // Find direct children in dir_trees (paths whose parent == "")
805805 for ( child_path, child_tree) in & dir_trees {
806- if let Some ( parent) = child_path. parent ( ) {
807- if parent. as_os_str ( ) . is_empty ( ) {
808- let child_name = child_path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
809- items . push ( TreeItem {
810- mode : TreeItemMode :: Tree ,
811- id : child_tree . id ,
812- name : child_name . to_string ( ) ,
813- } ) ;
814- }
806+ if let Some ( parent) = child_path. parent ( )
807+ && parent. as_os_str ( ) . is_empty ( )
808+ {
809+ let child_name = child_path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
810+ items . push ( TreeItem {
811+ mode : TreeItemMode :: Tree ,
812+ id : child_tree . id ,
813+ name : child_name . to_string ( ) ,
814+ } ) ;
815815 }
816816 }
817817
@@ -880,15 +880,15 @@ mod tests {
880880
881881 // Simulate the child directory linking logic
882882 for ( child_path, child_tree) in & dir_trees {
883- if let Some ( parent) = child_path. parent ( ) {
884- if parent == current_dir. as_path ( ) {
885- let child_name = child_path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
886- items . push ( TreeItem {
887- mode : TreeItemMode :: Tree ,
888- id : child_tree . id ,
889- name : child_name . to_string ( ) ,
890- } ) ;
891- }
883+ if let Some ( parent) = child_path. parent ( )
884+ && parent == current_dir. as_path ( )
885+ {
886+ let child_name = child_path . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
887+ items . push ( TreeItem {
888+ mode : TreeItemMode :: Tree ,
889+ id : child_tree . id ,
890+ name : child_name . to_string ( ) ,
891+ } ) ;
892892 }
893893 }
894894
0 commit comments