Skip to content

Commit

Permalink
Merge pull request #3753 from cgwalters/const-features
Browse files Browse the repository at this point in the history
utils: Clean up `get_features()`
  • Loading branch information
Luca Bruno authored Jun 10, 2022
2 parents d7823d1 + 8d69783 commit 939a63a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,21 +544,21 @@ pub(crate) fn varsubstitute(s: &str, subs: &Vec<crate::ffi::StringMapping>) -> C
Ok(varsubst(s, &m)?)
}

#[allow(clippy::vec_init_then_push)]
pub(crate) fn get_features() -> Vec<String> {
// These constant features were originally set in configure.ac, but have migrated to
// Rust in the interest in having less logic in autoconf.
let mut r = vec!["rust".to_string(), "compose".to_string()];
if cfg!(feature = "fedora-integration") {
r.push("fedora-integration".to_string());
}
if cfg!(feature = "bin-unit-tests") {
r.push("bin-unit-tests".to_string());
}
if cfg!(feature = "rhsm") {
r.push("rhsm".to_string());
}
r
let defaults = ["rust", "compose"].into_iter().map(Some);
let conditionals = [
cfg!(feature = "fedora-integration").then(|| "fedora-integration"),
cfg!(feature = "bin-unit-tests").then(|| "bin-unit-tests"),
cfg!(feature = "rhsm").then(|| "rhsm"),
]
.into_iter();
defaults
.chain(conditionals)
.flatten()
.map(String::from)
.collect()
}

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

0 comments on commit 939a63a

Please sign in to comment.