From f655656fb8cb6135b26e7960ce0b7adf96d6f567 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 4 Feb 2020 09:35:29 +0100 Subject: =?UTF-8?q?Streamline=20Key=20+=20Value=20traits=20=F0=9F=8C=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/expr.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/syntax/expr.rs') diff --git a/src/syntax/expr.rs b/src/syntax/expr.rs index e5c9489e..2f2eb68e 100644 --- a/src/syntax/expr.rs +++ b/src/syntax/expr.rs @@ -119,7 +119,7 @@ impl Tuple { /// Extract (and remove) the first matching value and remove and generate /// errors for all previous items that did not match. - pub fn get(&mut self, errors: &mut Errors) -> Option { + pub fn get(&mut self, errors: &mut Errors) -> Option { while !self.items.is_empty() { let expr = self.items.remove(0); let span = expr.span; @@ -134,7 +134,7 @@ impl Tuple { /// Extract and return an iterator over all values that match and generate /// errors for all items that do not match. pub fn get_all<'a, V: Value>(&'a mut self, errors: &'a mut Errors) - -> impl Iterator + 'a { + -> impl Iterator + 'a { self.items.drain(..).filter_map(move |expr| { let span = expr.span; match V::parse(expr) { @@ -204,7 +204,7 @@ impl Object { /// /// Inserts an error if the value does not match. If the key is not /// contained, no error is inserted. - pub fn get(&mut self, errors: &mut Errors, key: &str) -> Option { + pub fn get(&mut self, errors: &mut Errors, key: &str) -> Option { let index = self.pairs.iter().position(|pair| pair.key.v.as_str() == key)?; self.get_index::(errors, index) } @@ -216,7 +216,7 @@ impl Object { pub fn get_with_key( &mut self, errors: &mut Errors, - ) -> Option<(K::Output, V::Output)> { + ) -> Option<(K, V)> { for (index, pair) in self.pairs.iter().enumerate() { let key = Spanned { v: pair.key.v.as_str(), span: pair.key.span }; if let Some(key) = K::parse(key) { @@ -232,7 +232,7 @@ impl Object { pub fn get_all<'a, K: Key, V: Value>( &'a mut self, errors: &'a mut Errors, - ) -> impl Iterator + 'a { + ) -> impl Iterator + 'a { let mut index = 0; std::iter::from_fn(move || { if index < self.pairs.len() { @@ -261,14 +261,14 @@ impl Object { pub fn get_all_spanned<'a, K: Key + 'a, V: Value + 'a>( &'a mut self, errors: &'a mut Errors, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> + 'a { self.get_all::, Spanned>(errors) .map(|(k, v)| Spanned::new((k.v, v.v), Span::merge(k.span, v.span))) } /// Extract the argument at the given index and insert an error if the value /// does not match. - fn get_index(&mut self, errors: &mut Errors, index: usize) -> Option { + fn get_index(&mut self, errors: &mut Errors, index: usize) -> Option { let expr = self.pairs.remove(index).value; let span = expr.span; match V::parse(expr) { -- cgit v1.2.3