diff --git a/src/process.rs b/src/process.rs index 3411e11..a948427 100644 --- a/src/process.rs +++ b/src/process.rs @@ -101,7 +101,7 @@ impl<'src> Process<'src> { } } (WordPattern(w), val) => { - self.bind(w.to_string(), &val); + self.bind(w.to_string(), val); Some(self) } (AsPattern(word, type_str), value) => { @@ -209,7 +209,7 @@ impl<'src> Process<'src> { let to = self.locals.len(); let mut clauses = clauses.iter(); while let Some((Ast::MatchClause(patt, guard, body), _)) = clauses.next() { - if let Some(_) = self.match_pattern(&patt.0, value) { + if self.match_pattern(&patt.0, value).is_some() { let pass_guard = match guard.as_ref() { None => true, Some((ast, _)) => { @@ -232,7 +232,7 @@ impl<'src> Process<'src> { return res; } } - Err(LErr::new(format!("no match"))) + Err(LErr::new("no match".to_string())) } } @@ -259,7 +259,7 @@ impl<'src> Process<'src> { } (Fn(_f), Args(_args)) => todo!(), (_, Keyword(_)) => Ok(Nil), - (_, Args(_)) => Err(LErr::new(format!("you may only call a function"))), + (_, Args(_)) => Err(LErr::new("you may only call a function".to_string())), (Base(f), Tuple(args)) => match f { BaseFn::Nullary(f) => { let num_args = args.len(); @@ -334,7 +334,7 @@ impl<'src> Process<'src> { let to = self.locals.len(); let mut result = Value::Nil; for (expr, _) in exprs { - self.ast = &expr; + self.ast = expr; result = self.eval()?; } self.pop_to(to); @@ -360,9 +360,9 @@ impl<'src> Process<'src> { match to_splat { Value::List(list) => vect.append(list), _ => { - return Err(LErr::new(format!( - "only lists may be splatted into lists" - ))) + return Err(LErr::new( + "only lists may be splatted into lists".to_string(), + )) } } } else { @@ -392,7 +392,7 @@ impl<'src> Process<'src> { let val = self.eval()?; let result = match self.match_pattern(&patt.0, &val) { Some(_) => Ok(val), - None => Err(LErr::new(format!("no match"))), + None => Err(LErr::new("no match".to_string())), }; self.ast = parent; result @@ -429,7 +429,9 @@ impl<'src> Process<'src> { self.ast = term; let resolved = self.eval()?; let Value::Dict(to_splat) = resolved else { - return Err(LErr::new(format!("cannot splat non-dict into dict"))); + return Err(LErr::new( + "cannot splat non-dict into dict".to_string(), + )); }; dict = to_splat.union(dict); } @@ -477,7 +479,7 @@ impl<'src> Process<'src> { return result; }; } - Err(LErr::new(format!("no match"))) + Err(LErr::new("no match".to_string())) } Match(value, clauses) => { let parent = self.ast; @@ -508,7 +510,7 @@ impl<'src> Process<'src> { self.ast = ×.0; let times_num = match self.eval() { Ok(Value::Number(n)) => n as usize, - _ => return Err(LErr::new(format!("repeat may only take numbers"))), + _ => return Err(LErr::new("`repeat` may only take numbers".to_string())), }; self.ast = &body.0; for _ in 0..times_num {