Skip to content

Commit

Permalink
Use code that doesn't trip up clippy
Browse files Browse the repository at this point in the history
Reported upstream: rust-lang/rust-clippy#12785
  • Loading branch information
mqudsi committed May 9, 2024
1 parent f2163d6 commit d6d9928
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,7 @@ impl Target {
/// The libraries will be linked in the order they are provided in when testing, which may
/// influence the outcome.
pub fn has_libraries(&self, libraries: &[&str]) -> bool {
let stub = libraries
.first()
.map(|l| l.as_ref())
.unwrap_or("has_libraries");
let stub = libraries.first().copied().unwrap_or("has_libraries");
let snippet = snippet!("empty.c");
self.build(
stub,
Expand Down Expand Up @@ -614,7 +611,7 @@ impl Target {
/// Checks whether the [`cc::Build`] passed to [`Target::new()`] as configured can pull in the
/// named `headers` in the order they're provided.
pub fn has_headers(&self, headers: &[&str]) -> bool {
let stub = headers.first().map(|s| s.as_ref()).unwrap_or("has_headers");
let stub = headers.first().copied().unwrap_or("has_headers");
let snippet = format!(snippet!("has_header.c"), to_includes(headers));
self.build(
stub,
Expand Down Expand Up @@ -899,6 +896,6 @@ fn to_include(header: &str) -> String {
/// Convert one or more header filenames `headers` to `#include <..>` statements.
fn to_includes(headers: &[&str]) -> String {
let mut vec = Vec::with_capacity(headers.len());
vec.extend(headers.iter().map(|s| s.as_ref()).map(to_include));
vec.extend(headers.iter().copied().map(to_include));
vec.join("\n")
}

0 comments on commit d6d9928

Please sign in to comment.