Skip to content

Commit 939a63a

Browse files
author
Luca Bruno
authored
Merge pull request #3753 from cgwalters/const-features
utils: Clean up `get_features()`
2 parents d7823d1 + 8d69783 commit 939a63a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

rust/src/utils.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -544,21 +544,21 @@ pub(crate) fn varsubstitute(s: &str, subs: &Vec<crate::ffi::StringMapping>) -> C
544544
Ok(varsubst(s, &m)?)
545545
}
546546

547-
#[allow(clippy::vec_init_then_push)]
548547
pub(crate) fn get_features() -> Vec<String> {
549548
// These constant features were originally set in configure.ac, but have migrated to
550549
// Rust in the interest in having less logic in autoconf.
551-
let mut r = vec!["rust".to_string(), "compose".to_string()];
552-
if cfg!(feature = "fedora-integration") {
553-
r.push("fedora-integration".to_string());
554-
}
555-
if cfg!(feature = "bin-unit-tests") {
556-
r.push("bin-unit-tests".to_string());
557-
}
558-
if cfg!(feature = "rhsm") {
559-
r.push("rhsm".to_string());
560-
}
561-
r
550+
let defaults = ["rust", "compose"].into_iter().map(Some);
551+
let conditionals = [
552+
cfg!(feature = "fedora-integration").then(|| "fedora-integration"),
553+
cfg!(feature = "bin-unit-tests").then(|| "bin-unit-tests"),
554+
cfg!(feature = "rhsm").then(|| "rhsm"),
555+
]
556+
.into_iter();
557+
defaults
558+
.chain(conditionals)
559+
.flatten()
560+
.map(String::from)
561+
.collect()
562562
}
563563

564564
fn impl_sealed_memfd(description: &str, content: &[u8]) -> Result<std::fs::File> {

0 commit comments

Comments
 (0)