Use into_owned over to_string for Cow<str> (#39024)
This removes unnecessary allocations when the `Cow` is already owned Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -528,7 +528,7 @@ impl ContextProvider for GoContextProvider {
|
||||
let module_dir = buffer_dir
|
||||
.ancestors()
|
||||
.find(|dir| dir.join("go.mod").is_file())
|
||||
.map(|dir| dir.to_string_lossy().to_string())
|
||||
.map(|dir| dir.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| ".".to_string());
|
||||
|
||||
(GO_MODULE_ROOT_TASK_VARIABLE.clone(), module_dir)
|
||||
|
||||
@@ -1029,7 +1029,7 @@ fn test_fragment(variables: &TaskVariables, path: &Path, stem: &str) -> String {
|
||||
// filter out just that module.
|
||||
Some("--lib".to_owned())
|
||||
} else if stem == "mod" {
|
||||
maybe!({ Some(path.parent()?.file_name()?.to_string_lossy().to_string()) })
|
||||
maybe!({ Some(path.parent()?.file_name()?.to_string_lossy().into_owned()) })
|
||||
} else if stem == "main" {
|
||||
if let (Some(bin_name), Some(bin_kind)) = (
|
||||
variables.get(&RUST_BIN_NAME_TASK_VARIABLE),
|
||||
|
||||
Reference in New Issue
Block a user