follow clippy

This commit is contained in:
Scott Richmond 2024-12-11 15:48:24 -05:00
parent 5b41365caa
commit 65492d0810

View File

@ -101,7 +101,7 @@ impl<'src> Process<'src> {
} }
} }
(WordPattern(w), val) => { (WordPattern(w), val) => {
self.bind(w.to_string(), &val); self.bind(w.to_string(), val);
Some(self) Some(self)
} }
(AsPattern(word, type_str), value) => { (AsPattern(word, type_str), value) => {
@ -209,7 +209,7 @@ impl<'src> Process<'src> {
let to = self.locals.len(); let to = self.locals.len();
let mut clauses = clauses.iter(); let mut clauses = clauses.iter();
while let Some((Ast::MatchClause(patt, guard, body), _)) = clauses.next() { 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() { let pass_guard = match guard.as_ref() {
None => true, None => true,
Some((ast, _)) => { Some((ast, _)) => {
@ -232,7 +232,7 @@ impl<'src> Process<'src> {
return res; 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!(), (Fn(_f), Args(_args)) => todo!(),
(_, Keyword(_)) => Ok(Nil), (_, 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 { (Base(f), Tuple(args)) => match f {
BaseFn::Nullary(f) => { BaseFn::Nullary(f) => {
let num_args = args.len(); let num_args = args.len();
@ -334,7 +334,7 @@ impl<'src> Process<'src> {
let to = self.locals.len(); let to = self.locals.len();
let mut result = Value::Nil; let mut result = Value::Nil;
for (expr, _) in exprs { for (expr, _) in exprs {
self.ast = &expr; self.ast = expr;
result = self.eval()?; result = self.eval()?;
} }
self.pop_to(to); self.pop_to(to);
@ -360,9 +360,9 @@ impl<'src> Process<'src> {
match to_splat { match to_splat {
Value::List(list) => vect.append(list), Value::List(list) => vect.append(list),
_ => { _ => {
return Err(LErr::new(format!( return Err(LErr::new(
"only lists may be splatted into lists" "only lists may be splatted into lists".to_string(),
))) ))
} }
} }
} else { } else {
@ -392,7 +392,7 @@ impl<'src> Process<'src> {
let val = self.eval()?; let val = self.eval()?;
let result = match self.match_pattern(&patt.0, &val) { let result = match self.match_pattern(&patt.0, &val) {
Some(_) => Ok(val), Some(_) => Ok(val),
None => Err(LErr::new(format!("no match"))), None => Err(LErr::new("no match".to_string())),
}; };
self.ast = parent; self.ast = parent;
result result
@ -429,7 +429,9 @@ impl<'src> Process<'src> {
self.ast = term; self.ast = term;
let resolved = self.eval()?; let resolved = self.eval()?;
let Value::Dict(to_splat) = resolved else { 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); dict = to_splat.union(dict);
} }
@ -477,7 +479,7 @@ impl<'src> Process<'src> {
return result; return result;
}; };
} }
Err(LErr::new(format!("no match"))) Err(LErr::new("no match".to_string()))
} }
Match(value, clauses) => { Match(value, clauses) => {
let parent = self.ast; let parent = self.ast;
@ -508,7 +510,7 @@ impl<'src> Process<'src> {
self.ast = &times.0; self.ast = &times.0;
let times_num = match self.eval() { let times_num = match self.eval() {
Ok(Value::Number(n)) => n as usize, 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; self.ast = &body.0;
for _ in 0..times_num { for _ in 0..times_num {