iterator instead loop
This commit is contained in:
parent
8be306840f
commit
c97aa09117
1 changed files with 8 additions and 10 deletions
|
@ -113,17 +113,15 @@ pub fn to_llvm_feature(s: &str) -> &str {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_features(sess: &Session) -> Vec<Symbol> {
|
pub fn target_features(sess: &Session) -> Vec<Symbol> {
|
||||||
let whitelist = target_feature_whitelist(sess);
|
|
||||||
let target_machine = create_target_machine(sess);
|
let target_machine = create_target_machine(sess);
|
||||||
let mut features = Vec::new();
|
target_feature_whitelist(sess)
|
||||||
for feature in whitelist {
|
.iter()
|
||||||
let llvm_feature = to_llvm_feature(feature);
|
.filter(|feature| {
|
||||||
let ptr = CString::new(llvm_feature).as_ptr();
|
let llvm_feature = to_llvm_feature(feature);
|
||||||
if unsafe { llvm::LLVMRustHasFeature(target_machine, ptr) } {
|
let ptr = CString::new(llvm_feature).as_ptr();
|
||||||
features.push(Symbol::intern(feature));
|
unsafe { llvm::LLVMRustHasFeature(target_machine, ptr) }
|
||||||
}
|
})
|
||||||
}
|
.map(Symbol::intern).collect()
|
||||||
features
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_feature_whitelist(sess: &Session) -> &'static [&'static str] {
|
pub fn target_feature_whitelist(sess: &Session) -> &'static [&'static str] {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue