mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
use slightly more idiomatic api for cfg
This commit is contained in:
parent
93199002af
commit
355419d404
7 changed files with 59 additions and 40 deletions
|
@ -36,26 +36,20 @@ impl CfgOptions {
|
|||
self.check(&parse_cfg(attr))
|
||||
}
|
||||
|
||||
pub fn atom(mut self, name: SmolStr) -> CfgOptions {
|
||||
self.atoms.insert(name);
|
||||
self
|
||||
pub fn insert_atom(&mut self, key: SmolStr) {
|
||||
self.atoms.insert(key);
|
||||
}
|
||||
|
||||
pub fn key_value(mut self, key: SmolStr, value: SmolStr) -> CfgOptions {
|
||||
pub fn remove_atom(&mut self, name: &str) {
|
||||
self.atoms.remove(name);
|
||||
}
|
||||
|
||||
pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) {
|
||||
self.key_values.insert((key, value));
|
||||
self
|
||||
}
|
||||
|
||||
/// Shortcut to set features
|
||||
pub fn features(mut self, iter: impl IntoIterator<Item = SmolStr>) -> CfgOptions {
|
||||
for feat in iter {
|
||||
self = self.key_value("feature".into(), feat);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
pub fn remove_atom(mut self, name: &SmolStr) -> CfgOptions {
|
||||
self.atoms.remove(name);
|
||||
self
|
||||
pub fn insert_features(&mut self, iter: impl IntoIterator<Item = SmolStr>) {
|
||||
iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue