diff --git a/tools/codegen/src/main.rs b/tools/codegen/src/main.rs index f66c132c..35999ddd 100644 --- a/tools/codegen/src/main.rs +++ b/tools/codegen/src/main.rs @@ -172,7 +172,7 @@ fn main() -> Result<()> { if let Some(license) = detail.license { eprintln!("Trying to using license '{license}' from crates.io ..."); if let Some(license_markdown) = - get_license_markdown(&license, &repo.to_string(), &repo_info.default_branch) + get_license_markdown(&license, repo, &repo_info.default_branch) { manifests.license_markdown = license_markdown; } @@ -181,7 +181,7 @@ fn main() -> Result<()> { if let Some(license) = license.spdx_id { eprintln!("Trying to using license '{license}' from github.com ..."); if let Some(license_markdown) = - get_license_markdown(&license, &repo.to_string(), &repo_info.default_branch) + get_license_markdown(&license, repo, &repo_info.default_branch) { manifests.license_markdown = license_markdown; } @@ -687,16 +687,16 @@ pub fn download(url: &str) -> Result { } #[must_use] -fn create_github_raw_link(repository: &String, branch: &String, filename: &String) -> String { +fn create_github_raw_link(repository: &str, branch: &str, filename: &str) -> String { format!("https://raw.githubusercontent.com/{repository}/{branch}/{filename}") } #[must_use] -fn create_github_link(repository: &String, branch: &String, filename: &String) -> String { +fn create_github_link(repository: &str, branch: &str, filename: &str) -> String { format!("https://github.com/{repository}/blob/{branch}/{filename}") } #[must_use] -fn get_license_markdown(spdx_expr: &str, repo: &String, default_branch: &String) -> Option { +fn get_license_markdown(spdx_expr: &str, repo: &str, default_branch: &str) -> Option { // TODO: use https://docs.rs/spdx/latest/spdx/expression/struct.Expression.html#method.canonicalize ? let expr = spdx::Expression::parse_mode(spdx_expr, spdx::ParseMode::LAX).unwrap(); @@ -740,14 +740,14 @@ fn get_license_markdown(spdx_expr: &str, repo: &String, default_branch: &String) let license_name = if let Some(exception_id) = exception_id { format!("{} WITH {}", license_id.name, exception_id.name) } else { - license_id.name.to_string() + license_id.name.to_owned() }; let name = license_id.name.split('-').next().unwrap().to_ascii_uppercase(); for filename in [ - "LICENSE".to_string(), + "LICENSE".to_owned(), format!("LICENSE-{name}"), - "LICENSE.md".to_string(), - "COPYING".to_string(), + "LICENSE.md".to_owned(), + "COPYING".to_owned(), ] { let url = create_github_raw_link(repo, default_branch, &filename); if github_head(&url).is_ok() { @@ -765,7 +765,7 @@ fn get_license_markdown(spdx_expr: &str, repo: &String, default_branch: &String) let license_name = if let Some(exception_id) = exception_id { format!("{} WITH {}", license_id.name, exception_id.name) } else { - license_id.name.to_string() + license_id.name.to_owned() }; if github_head(&url).is_ok() { let url = create_github_link(repo, default_branch, &filename); diff --git a/tools/codegen/src/tools-markdown.rs b/tools/codegen/src/tools-markdown.rs index f867520a..bd3c8d10 100644 --- a/tools/codegen/src/tools-markdown.rs +++ b/tools/codegen/src/tools-markdown.rs @@ -46,16 +46,16 @@ fn main() -> Result<()> { paths.sort_by_key(fs_err::DirEntry::path); let mut tools = vec![MarkdownEntry { - name: "valgrind".to_string(), + name: "valgrind".to_owned(), alias: None, - website: "https://valgrind.org/".to_string(), + website: "https://valgrind.org/".to_owned(), installed_to: InstalledTo::Snap, installed_from: InstalledFrom::Snap, platforms: Platforms { linux: true, ..Default::default() }, - repository: "https://sourceware.org/git/valgrind.git".to_string(), + repository: "https://sourceware.org/git/valgrind.git".to_owned(), license_markdown: "[GPL-2.0](https://sourceware.org/git/?p=valgrind.git;a=blob;f=COPYING;hb=HEAD)" - .to_string(), + .to_owned(), }]; for path in paths {