aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cfg/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-08 12:22:49 +0100
committerAleksey Kladov <[email protected]>2019-10-08 12:22:49 +0100
commit355419d4044704d13a902641d86ad5501af8714d (patch)
treef5803e2159d56145f83e4d08170f4e475a75ebb2 /crates/ra_cfg/src
parent93199002af05f3a3dfd274fe10633372f2471b73 (diff)
use slightly more idiomatic api for cfg
Diffstat (limited to 'crates/ra_cfg/src')
-rw-r--r--crates/ra_cfg/src/lib.rs24
1 files changed, 9 insertions, 15 deletions
diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs
index e1c92fbba..1bee3eb99 100644
--- a/crates/ra_cfg/src/lib.rs
+++ b/crates/ra_cfg/src/lib.rs
@@ -36,26 +36,20 @@ impl CfgOptions {
36 self.check(&parse_cfg(attr)) 36 self.check(&parse_cfg(attr))
37 } 37 }
38 38
39 pub fn atom(mut self, name: SmolStr) -> CfgOptions { 39 pub fn insert_atom(&mut self, key: SmolStr) {
40 self.atoms.insert(name); 40 self.atoms.insert(key);
41 self
42 } 41 }
43 42
44 pub fn key_value(mut self, key: SmolStr, value: SmolStr) -> CfgOptions { 43 pub fn remove_atom(&mut self, name: &str) {
45 self.key_values.insert((key, value)); 44 self.atoms.remove(name);
46 self
47 } 45 }
48 46
49 /// Shortcut to set features 47 pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) {
50 pub fn features(mut self, iter: impl IntoIterator<Item = SmolStr>) -> CfgOptions { 48 self.key_values.insert((key, value));
51 for feat in iter {
52 self = self.key_value("feature".into(), feat);
53 }
54 self
55 } 49 }
56 50
57 pub fn remove_atom(mut self, name: &SmolStr) -> CfgOptions { 51 /// Shortcut to set features
58 self.atoms.remove(name); 52 pub fn insert_features(&mut self, iter: impl IntoIterator<Item = SmolStr>) {
59 self 53 iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat));
60 } 54 }
61} 55}