浏览代码

Formatting

David Peter 2 年之前
父节点
当前提交
2a6e11aad1
共有 2 个文件被更改,包括 16 次插入11 次删除
  1. 10 4
      numbat-exchange-rates/src/lib.rs
  2. 6 7
      numbat/src/tokenizer.rs

+ 10 - 4
numbat-exchange-rates/src/lib.rs

@@ -9,8 +9,10 @@ pub fn fetch_exchange_rates() -> Option<ExchangeRates> {
     let mut rates = ExchangeRates::default();
 
     let xml =
-        reqwest::blocking::get("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml").ok()?
-            .text().ok()?;
+        reqwest::blocking::get("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml")
+            .ok()?
+            .text()
+            .ok()?;
 
     let mut reader = Reader::from_str(&xml);
     loop {
@@ -20,13 +22,17 @@ pub fn fetch_exchange_rates() -> Option<ExchangeRates> {
                 if e.local_name().as_ref() != b"Cube" {
                     continue;
                 }
-                let currency = &e.try_get_attribute("currency").ok()??.unescape_value().ok()?;
+                let currency = &e
+                    .try_get_attribute("currency")
+                    .ok()??
+                    .unescape_value()
+                    .ok()?;
                 let rate = &e.try_get_attribute("rate").ok()??.unescape_value().ok()?;
                 let rate = rate.parse().ok()?;
 
                 rates.insert(currency.to_string(), rate);
             }
-            _ => {},
+            _ => {}
         }
     }
 

+ 6 - 7
numbat/src/tokenizer.rs

@@ -181,7 +181,11 @@ impl Tokenizer {
         }
 
         let mut last_char = None;
-        while self.peek().map(|c| c.is_ascii_digit() || c == '_').unwrap_or(false) {
+        while self
+            .peek()
+            .map(|c| c.is_ascii_digit() || c == '_')
+            .unwrap_or(false)
+        {
             last_char = Some(self.advance());
         }
 
@@ -193,12 +197,7 @@ impl Tokenizer {
             });
         }
 
-        if disallow_dot_after_stream
-            && self
-                .peek()
-                .map(|c| c == '.')
-                .unwrap_or(false)
-        {
+        if disallow_dot_after_stream && self.peek().map(|c| c == '.').unwrap_or(false) {
             return Err(TokenizerError {
                 kind: TokenizerErrorKind::UnexpectedCharacterInNumberLiteral(self.peek().unwrap()),
                 span: self.current.single_character_span(self.code_source_index),