diff --git a/src/commands/tui/diff.rs b/src/commands/tui/diff.rs index 2dea86502..c0c9bb9b1 100644 --- a/src/commands/tui/diff.rs +++ b/src/commands/tui/diff.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsString, path::PathBuf}; +use std::{borrow::Cow, ffi::OsStr, path::PathBuf}; use anyhow::Result; use crossterm::event::{Event, KeyCode, KeyEventKind}; @@ -80,7 +80,7 @@ impl DiffNode { } } - fn name(&self) -> OsString { + fn name(&self) -> Cow<'_, OsStr> { self.0.as_ref().reduce(|l, _| l).name() } diff --git a/src/commands/tui/summary.rs b/src/commands/tui/summary.rs index 40e2004c5..f9f69a3b5 100644 --- a/src/commands/tui/summary.rs +++ b/src/commands/tui/summary.rs @@ -118,11 +118,8 @@ impl TreeSummary { let mut tree_without_meta = Tree::default(); p.inc(1); for node in &tree.nodes { - let mut node_without_meta = Node::new_node( - node.name().as_os_str(), - node.node_type.clone(), - Metadata::default(), - ); + let mut node_without_meta = + Node::new_node(&node.name(), node.node_type.clone(), Metadata::default()); node_without_meta.content = node.content.clone(); summary.update_from_node(node); if let Some(id) = node.subtree { diff --git a/src/commands/webdav/webdavfs.rs b/src/commands/webdav/webdavfs.rs index 022cb7e25..daf9c6a7f 100644 --- a/src/commands/webdav/webdavfs.rs +++ b/src/commands/webdav/webdavfs.rs @@ -239,12 +239,7 @@ impl DavDirEntry for DavFsDirEntry { #[cfg(windows)] fn name(&self) -> Vec { - self.0 - .name() - .as_os_str() - .to_string_lossy() - .to_string() - .into_bytes() + self.0.name().to_string_lossy().to_string().into_bytes() } }