From 5fffbdef2ae599bd6d014a80b3a983143a5c6d8c Mon Sep 17 00:00:00 2001 From: Vivek Kethineni Date: Tue, 28 Jan 2025 18:47:12 -0600 Subject: [PATCH] push to pathbuf instead of creating string --- crates/nu-command/src/path/relative_to.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/nu-command/src/path/relative_to.rs b/crates/nu-command/src/path/relative_to.rs index bd91e38391..5ca6c584f7 100644 --- a/crates/nu-command/src/path/relative_to.rs +++ b/crates/nu-command/src/path/relative_to.rs @@ -162,11 +162,12 @@ fn relative_to(path: &Path, span: Span, args: &Arguments) -> Value { } }; - let mut path: String = differing_parent.iter().map(|_| "../").collect(); + let mut path = PathBuf::new(); + differing_parent.iter().for_each(|_| path.push("..")); - path.push_str(&differing_child.to_string_lossy()); + path.push(&differing_child); - Value::string(path, span) + Value::string(path.to_string_lossy(), span) } #[cfg(test)] mod tests {