Skip to content

Commit

Permalink
Simple way to create CfgResult from bool
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 18, 2022
1 parent 28b9214 commit 70453b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 10 additions & 0 deletions gen/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,13 @@ impl Api {
}
}
}

impl From<bool> for CfgResult {
fn from(value: bool) -> Self {
if value {
CfgResult::True
} else {
CfgResult::False
}
}
}
6 changes: 1 addition & 5 deletions gen/src/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@ pub(super) trait CfgEvaluator {
}

pub(super) enum CfgResult {
#[allow(dead_code)]
True,
#[allow(dead_code)]
False,
Undetermined {
msg: String,
},
Undetermined { msg: String },
}

/// Results of code generation.
Expand Down

0 comments on commit 70453b3

Please sign in to comment.