forked from AbleScript/ablescript
Clippy
This commit is contained in:
parent
a33a3ddd7f
commit
23f03e7f67
|
@ -21,7 +21,7 @@ use rand::random;
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Expr, ExprKind, Iden, Stmt, StmtKind},
|
ast::{Expr, ExprKind, Iden, Stmt, StmtKind},
|
||||||
base_55,
|
base_55,
|
||||||
consts::{self, ablescript_consts},
|
consts::ablescript_consts,
|
||||||
error::{Error, ErrorKind},
|
error::{Error, ErrorKind},
|
||||||
variables::{Functio, Value, Variable},
|
variables::{Functio, Value, Variable},
|
||||||
};
|
};
|
||||||
|
@ -134,7 +134,6 @@ impl ExecEnv {
|
||||||
fn eval_expr(&self, expr: &Expr) -> Result<Value, Error> {
|
fn eval_expr(&self, expr: &Expr) -> Result<Value, Error> {
|
||||||
use crate::ast::BinOpKind::*;
|
use crate::ast::BinOpKind::*;
|
||||||
use crate::ast::ExprKind::*;
|
use crate::ast::ExprKind::*;
|
||||||
use Value::*;
|
|
||||||
|
|
||||||
Ok(match &expr.kind {
|
Ok(match &expr.kind {
|
||||||
BinOp { lhs, rhs, kind } => {
|
BinOp { lhs, rhs, kind } => {
|
||||||
|
@ -345,7 +344,7 @@ impl ExecEnv {
|
||||||
res?;
|
res?;
|
||||||
}
|
}
|
||||||
Functio::Eval(code) => {
|
Functio::Eval(code) => {
|
||||||
if args.len() != 0 {
|
if !args.is_empty() {
|
||||||
return Err(Error {
|
return Err(Error {
|
||||||
kind: ErrorKind::MismatchedArgumentError,
|
kind: ErrorKind::MismatchedArgumentError,
|
||||||
span: span.to_owned(),
|
span: span.to_owned(),
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell, collections::HashMap, fmt::Display, hash::Hash, io::Write, mem::discriminant,
|
||||||
collections::HashMap,
|
ops, rc::Rc, vec,
|
||||||
convert::{TryFrom, TryInto},
|
|
||||||
fmt::Display,
|
|
||||||
hash::Hash,
|
|
||||||
io::Write,
|
|
||||||
mem::discriminant,
|
|
||||||
ops,
|
|
||||||
rc::Rc,
|
|
||||||
vec,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
@ -424,9 +416,7 @@ impl ops::Div for Value {
|
||||||
.map(|(k, v)| {
|
.map(|(k, v)| {
|
||||||
(
|
(
|
||||||
Value::Int(k as i32 + 1),
|
Value::Int(k as i32 + 1),
|
||||||
Rc::new(RefCell::new(Value::Cart(
|
Rc::new(RefCell::new(Value::Cart(v.iter().cloned().collect()))),
|
||||||
v.into_iter().cloned().collect(),
|
|
||||||
))),
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
@ -465,13 +455,7 @@ impl PartialEq for Value {
|
||||||
let other = other.clone();
|
let other = other.clone();
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Value::Nul => {
|
Value::Nul => matches!(other, Value::Nul),
|
||||||
if let Value::Nul = other {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Value::Str(s) => *s == other.to_string(),
|
Value::Str(s) => *s == other.to_string(),
|
||||||
Value::Int(i) => *i == other.into_i32(),
|
Value::Int(i) => *i == other.into_i32(),
|
||||||
Value::Bool(b) => *b == other.into_bool(),
|
Value::Bool(b) => *b == other.into_bool(),
|
||||||
|
@ -542,8 +526,8 @@ impl Display for Value {
|
||||||
},
|
},
|
||||||
Value::Cart(c) => {
|
Value::Cart(c) => {
|
||||||
write!(f, "[")?;
|
write!(f, "[")?;
|
||||||
let mut cart_vec = c.into_iter().collect::<Vec<_>>();
|
let mut cart_vec = c.iter().collect::<Vec<_>>();
|
||||||
cart_vec.sort_by(|x, y| x.0.partial_cmp(&y.0).unwrap_or(std::cmp::Ordering::Less));
|
cart_vec.sort_by(|x, y| x.0.partial_cmp(y.0).unwrap_or(std::cmp::Ordering::Less));
|
||||||
|
|
||||||
for (key, value) in cart_vec {
|
for (key, value) in cart_vec {
|
||||||
write!(f, "{} <= {}, ", value.borrow(), key)?;
|
write!(f, "{} <= {}, ", value.borrow(), key)?;
|
||||||
|
|
Loading…
Reference in a new issue