From 12e3b4c70b5ef23b2fdfc197296d483680e125f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 8 Feb 2019 14:49:43 +0300 Subject: reformat the world --- crates/test_utils/src/lib.rs | 37 +++++++++++-------------------------- crates/test_utils/src/marks.rs | 5 +---- 2 files changed, 12 insertions(+), 30 deletions(-) (limited to 'crates/test_utils/src') diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 35a679aea..09fc2e659 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -85,9 +85,7 @@ pub fn extract_ranges(mut text: &str, tag: &str) -> (Vec, String) { stack.push(from); } else if text.starts_with(&close) { text = &text[close.len()..]; - let from = stack - .pop() - .unwrap_or_else(|| panic!("unmatched ", tag)); + let from = stack.pop().unwrap_or_else(|| panic!("unmatched ", tag)); let to = TextUnit::of_str(&res); ranges.push(TextRange::from_to(from, to)); } @@ -131,10 +129,7 @@ pub fn parse_fixture(fixture: &str) -> Vec { macro_rules! flush { () => { if let Some(meta) = meta { - res.push(FixtureEntry { - meta: meta.to_string(), - text: buf.clone(), - }); + res.push(FixtureEntry { meta: meta.to_string(), text: buf.clone() }); buf.clear(); } }; @@ -226,15 +221,13 @@ pub fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a let mut l = l.iter().collect::>(); let mut r = r.iter().collect::>(); - l.retain( - |l| match r.iter().position(|r| find_mismatch(l, r).is_none()) { - Some(i) => { - r.remove(i); - false - } - None => true, - }, - ); + l.retain(|l| match r.iter().position(|r| find_mismatch(l, r).is_none()) { + Some(i) => { + r.remove(i); + false + } + None => true, + }); if !l.is_empty() { assert!(!r.is_empty()); @@ -250,10 +243,7 @@ pub fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a return Some((expected, actual)); } - l.values() - .zip(r.values()) - .filter_map(|(l, r)| find_mismatch(l, r)) - .nth(0) + l.values().zip(r.values()).filter_map(|(l, r)| find_mismatch(l, r)).nth(0) } (&Null, &Null) => None, // magic string literal "{...}" acts as wildcard for any sub-JSON @@ -312,12 +302,7 @@ fn test_from_dir(dir: &Path) -> Vec { pub fn project_dir() -> PathBuf { let dir = env!("CARGO_MANIFEST_DIR"); - PathBuf::from(dir) - .parent() - .unwrap() - .parent() - .unwrap() - .to_owned() + PathBuf::from(dir).parent().unwrap().parent().unwrap().to_owned() } /// Read file and normalize newlines. diff --git a/crates/test_utils/src/marks.rs b/crates/test_utils/src/marks.rs index ee47b5219..d2a84643c 100644 --- a/crates/test_utils/src/marks.rs +++ b/crates/test_utils/src/marks.rs @@ -64,10 +64,7 @@ pub struct MarkChecker { impl MarkChecker { pub fn new(mark: &'static AtomicUsize) -> MarkChecker { let value_on_entry = mark.load(Ordering::SeqCst); - MarkChecker { - mark, - value_on_entry, - } + MarkChecker { mark, value_on_entry } } } -- cgit v1.2.3