Skip to content

Commit 8250cc0

Browse files
committed
Use Cow::into_owned to only clone when necessary
1 parent 60b9351 commit 8250cc0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cli/self_update.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static UPDATE_ROOT: &str = "https://static.rust-lang.org/rustup";
215215
/// substituted for the directory prefix
216216
fn canonical_cargo_home() -> Result<String> {
217217
let path = utils::cargo_home()?;
218-
let mut path_str = path.to_string_lossy().to_string();
218+
let mut path_str = path.to_string_lossy().into_owned();
219219

220220
let default_cargo_home = utils::home_dir()
221221
.unwrap_or_else(|| PathBuf::from("."))
@@ -1168,7 +1168,7 @@ fn do_add_to_path(methods: &[PathUpdateMethod]) -> Result<()> {
11681168
let mut new_path = utils::cargo_home()?
11691169
.join("bin")
11701170
.to_string_lossy()
1171-
.to_string();
1171+
.into_owned();
11721172
if old_path.contains(&new_path) {
11731173
return Ok(());
11741174
}
@@ -1283,7 +1283,7 @@ fn do_remove_from_path(methods: &[PathUpdateMethod]) -> Result<()> {
12831283
let path_str = utils::cargo_home()?
12841284
.join("bin")
12851285
.to_string_lossy()
1286-
.to_string();
1286+
.into_owned();
12871287
let idx = if let Some(i) = old_path.find(&path_str) {
12881288
i
12891289
} else {

0 commit comments

Comments
 (0)