Browse Source

address lints

Getty Ritter 1 year ago
parent
commit
96edbcf218
3 changed files with 5 additions and 4 deletions
  1. 1 1
      src/ast.rs
  2. 1 1
      src/interp.rs
  3. 3 2
      tools/regenerate.rs

+ 1 - 1
src/ast.rs

@@ -94,7 +94,7 @@ impl ASTArena {
                 }
             }
         }
-        let end_of_line = end_of_line.unwrap_or_else(|| src.len());
+        let end_of_line = end_of_line.unwrap_or(src.len());
 
         let mut result = format!("{:3} |", line_number);
         result.push_str(&src[start_of_line..end_of_line]);

+ 1 - 1
src/interp.rs

@@ -77,7 +77,7 @@ impl Value {
         match self {
             Value::Nil => f(""),
             Value::Lit(Literal::Str(s)) => f(s),
-            Value::Lit(Literal::Atom(s)) => f(&format!("{}", &ast[s.item])),
+            Value::Lit(Literal::Atom(s)) => f(&ast[s.item].to_string()),
             Value::Lit(Literal::Num(n)) => f(&format!("{}", n)),
             Value::Tup(values) => {
                 let mut buf = String::new();

+ 3 - 2
tools/regenerate.rs

@@ -3,6 +3,7 @@ use matzo::interp;
 use matzo::lexer;
 
 use std::collections::BTreeMap;
+use std::collections::btree_map::Entry;
 use std::io::Write;
 
 const MAX_RUN_EXPECTATIONS: u64 = 64;
@@ -14,8 +15,8 @@ fn generate_runs(source: &str) -> Result<BTreeMap<String, String>, Box<dyn std::
         let mut out = Vec::new();
         state.run_with_writer(source, &mut out)?;
         let out = std::str::from_utf8(&out).unwrap().trim().to_string();
-        if !found_results.contains_key(&out) {
-            let _ = found_results.insert(out, seed);
+        if  let Entry::Vacant(e) = found_results.entry(out) {
+            e.insert(seed);
         }
     }
     let output = found_results