From 355419d4044704d13a902641d86ad5501af8714d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Oct 2019 14:22:49 +0300 Subject: use slightly more idiomatic api for cfg --- crates/ra_cfg/src/lib.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'crates/ra_cfg') 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 { 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 { - self.key_values.insert((key, value)); - self + pub fn remove_atom(&mut self, name: &str) { + self.atoms.remove(name); } - /// Shortcut to set features - pub fn features(mut self, iter: impl IntoIterator) -> CfgOptions { - for feat in iter { - self = self.key_value("feature".into(), feat); - } - self + pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) { + self.key_values.insert((key, value)); } - pub fn remove_atom(mut self, name: &SmolStr) -> CfgOptions { - self.atoms.remove(name); - self + /// Shortcut to set features + pub fn insert_features(&mut self, iter: impl IntoIterator) { + iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat)); } } -- cgit v1.2.3