From b9ba155c26700f98f55229ba9bf04bf850b6a233 Mon Sep 17 00:00:00 2001 From: Benjamin Nguyen Date: Sun, 5 Mar 2023 09:05:52 -0800 Subject: [PATCH] path as string when file name can't be ascertained --- src/fs/erdtree/node.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fs/erdtree/node.rs b/src/fs/erdtree/node.rs index 5f8caeee..c7183f72 100644 --- a/src/fs/erdtree/node.rs +++ b/src/fs/erdtree/node.rs @@ -228,7 +228,10 @@ impl From for Node { .ok() .flatten(); - let file_name = path.file_name().map(|os_str| os_str.to_owned()).unwrap(); + let file_name = path.file_name().map_or_else( + || OsString::from(path.display().to_string()), + |os_str| os_str.to_owned(), + ); let style = get_ls_colors() .style_for_path_with_metadata(path, metadata.as_ref())