Skip to content

Commit

Permalink
Use clone_from/clone_into
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero committed May 3, 2024
1 parent a3e322d commit 93c9cee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -9,7 +9,7 @@ readme = "README.md"
repository = "https://github.com/lu-zero/cargo-c"
categories = ["command-line-utilities", "development-tools::cargo-plugins"]
keywords = ["cargo", "cdylib"]
rust-version = "1.75"
rust-version = "1.76"

[[bin]]
name = "cargo-capi"
Expand Down
8 changes: 4 additions & 4 deletions src/pkg_config_gen.rs
Expand Up @@ -129,15 +129,15 @@ impl PkgConfig {
) -> Self {
let mut pc = PkgConfig::new(name, capi_config);

pc.prefix = install_paths.prefix.clone();
pc.prefix.clone_from(&install_paths.prefix);
// TODO: support exec_prefix
if args.contains_id("includedir") {
if let Ok(suffix) = install_paths.includedir.strip_prefix(&pc.prefix) {
let mut includedir = PathBuf::from("${prefix}");
includedir.push(suffix);
pc.includedir = includedir;
} else {
pc.includedir = install_paths.includedir.clone();
pc.includedir.clone_from(&install_paths.includedir);
}
}
if args.contains_id("libdir") {
Expand All @@ -146,7 +146,7 @@ impl PkgConfig {
libdir.push(suffix);
pc.libdir = libdir;
} else {
pc.libdir = install_paths.libdir.clone();
pc.libdir.clone_from(&install_paths.libdir);
}
}
pc
Expand All @@ -164,7 +164,7 @@ impl PkgConfig {
}

pub fn set_description<S: AsRef<str>>(&mut self, descr: S) -> &mut Self {
self.description = descr.as_ref().to_owned();
descr.as_ref().clone_into(&mut self.description);
self
}

Expand Down

0 comments on commit 93c9cee

Please sign in to comment.