From 3f8a60627fe15158e24d8c72c4127845a5476bf3 Mon Sep 17 00:00:00 2001 From: Tibo Delor Date: Thu, 13 Dec 2018 18:35:01 +1100 Subject: [PATCH] Format using rustfmt 1.0 --- saphyr/src/emitter.rs | 2 +- saphyr/src/scanner.rs | 22 +++++++++++++--------- saphyr/src/yaml.rs | 15 ++++++++++----- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/saphyr/src/emitter.rs b/saphyr/src/emitter.rs index 8a0b60a..09e9f87 100644 --- a/saphyr/src/emitter.rs +++ b/saphyr/src/emitter.rs @@ -334,7 +334,7 @@ fn need_quotes(string: &str) -> bool { // http://yaml.org/type/null.html "null", "Null", "NULL", "~", ] - .contains(&string) + .contains(&string) || string.starts_with('.') || string.parse::().is_ok() || string.parse::().is_ok() diff --git a/saphyr/src/scanner.rs b/saphyr/src/scanner.rs index b8ade61..4eb7912 100644 --- a/saphyr/src/scanner.rs +++ b/saphyr/src/scanner.rs @@ -483,10 +483,12 @@ impl> Scanner { self.allow_simple_key(); } } - '#' => while !is_breakz(self.ch()) { - self.skip(); - self.lookahead(1); - }, + '#' => { + while !is_breakz(self.ch()) { + self.skip(); + self.lookahead(1); + } + } _ => break, } } @@ -929,11 +931,13 @@ impl> Scanner { self.lookahead(1); } - if string.is_empty() || match self.ch() { - c if is_blankz(c) => false, - '?' | ':' | ',' | ']' | '}' | '%' | '@' | '`' => false, - _ => true, - } { + if string.is_empty() + || match self.ch() { + c if is_blankz(c) => false, + '?' | ':' | ',' | ']' | '}' | '%' | '@' | '`' => false, + _ => true, + } + { return Err(ScanError::new(start_mark, "while scanning an anchor or alias, did not find expected alphabetic or numeric character")); } diff --git a/saphyr/src/yaml.rs b/saphyr/src/yaml.rs index e2acf39..6ccbec3 100644 --- a/saphyr/src/yaml.rs +++ b/saphyr/src/yaml.rs @@ -409,7 +409,8 @@ a4: a5: 'single_quoted' a6: \"double_quoted\" a7: 你好 -".to_owned(); +" + .to_owned(); let out = YamlLoader::load_from_str(&s).unwrap(); let doc = &out[0]; assert_eq!(doc["a7"].as_str().unwrap(), "你好"); @@ -652,7 +653,8 @@ hash: with: indentations "#, - ).unwrap() + ) + .unwrap() .into_iter() .next() .unwrap(); @@ -663,7 +665,8 @@ hash: with: indentations "#, - ).unwrap() + ) + .unwrap() .into_iter() .next() .unwrap(); @@ -674,7 +677,8 @@ hash: with: indentations "#, - ).unwrap() + ) + .unwrap() .into_iter() .next() .unwrap(); @@ -685,7 +689,8 @@ hash: with: indentations "#, - ).unwrap() + ) + .unwrap() .into_iter() .next() .unwrap();