resolve clippy lints

This commit is contained in:
Connor Skees 2020-07-07 01:13:15 -04:00
parent 57562b52d3
commit 790573195f
5 changed files with 24 additions and 28 deletions

View File

@ -49,6 +49,8 @@ impl PartialEq for Builtin {
}
}
impl Eq for Builtin {}
pub(crate) static GLOBAL_FUNCTIONS: Lazy<GlobalFunctionMap> = Lazy::new(|| {
let mut m = HashMap::new();
color::declare(&mut m);

View File

@ -84,8 +84,8 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
Op::Rem => self.rem(val1, val2)?,
Op::And => Self::and(val1, val2)?,
Op::Or => Self::or(val1, val2)?,
Op::Equal => self.equal(val1, val2),
Op::NotEqual => self.not_equal(val1, val2),
Op::Equal => Self::equal(val1, val2),
Op::NotEqual => Self::not_equal(val1, val2),
Op::GreaterThan => self.greater_than(val1, val2)?,
Op::GreaterThanEqual => self.greater_than_or_equal(val1, val2)?,
Op::LessThan => self.less_than(val1, val2)?,
@ -672,7 +672,7 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
Ok(if left.is_true() { left } else { right })
}
pub fn equal(&self, left: HigherIntermediateValue, right: HigherIntermediateValue) -> Value {
pub fn equal(left: HigherIntermediateValue, right: HigherIntermediateValue) -> Value {
let left = match left {
HigherIntermediateValue::Literal(v) => v,
v => panic!("{:?}", v),
@ -684,7 +684,7 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
Value::bool(left.equals(&right))
}
fn not_equal(&self, left: HigherIntermediateValue, right: HigherIntermediateValue) -> Value {
fn not_equal(left: HigherIntermediateValue, right: HigherIntermediateValue) -> Value {
let left = match left {
HigherIntermediateValue::Literal(v) => v,
v => panic!("{:?}", v),

View File

@ -1,4 +1,9 @@
use std::{collections::HashSet, slice::Iter, vec::IntoIter};
use std::{
collections::HashSet,
hash::{Hash, Hasher},
slice::Iter,
vec::IntoIter,
};
use crate::{
common::{Brackets, ListSeparator},
@ -6,7 +11,7 @@ use crate::{
value::Value,
};
#[derive(Debug, Clone, Hash)]
#[derive(Debug, Clone)]
pub(crate) struct SassMap(Vec<(Value, Value)>);
impl PartialEq for SassMap {
@ -19,6 +24,12 @@ impl PartialEq for SassMap {
impl Eq for SassMap {}
impl Hash for SassMap {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.hash(state)
}
}
impl SassMap {
pub const fn new() -> SassMap {
SassMap(Vec::new())
@ -26,7 +37,7 @@ impl SassMap {
pub fn get(self, key: &Value) -> SassResult<Option<Value>> {
for (k, v) in self.0 {
if k.equals(&key) {
if k.equals(key) {
return Ok(Some(v));
}
}

View File

@ -257,7 +257,7 @@ impl Value {
},
Value::Dimension(n, unit) => match other {
Value::Dimension(n2, unit2) => {
if !unit.comparable(&unit2) {
if !unit.comparable(unit2) {
false
} else if unit == unit2 {
n == n2
@ -277,7 +277,7 @@ impl Value {
if sep1 != sep2 || brackets1 != brackets2 || list1.len() != list2.len() {
false
} else {
for (a, b) in list1.into_iter().zip(list2) {
for (a, b) in list1.iter().zip(list2) {
if !a.equals(b) {
return false;
}
@ -299,7 +299,7 @@ impl Value {
},
Value::Dimension(n, unit) => match other {
Value::Dimension(n2, unit2) => {
if !unit.comparable(&unit2) {
if !unit.comparable(unit2) {
true
} else if unit == unit2 {
n != n2

View File

@ -22,7 +22,7 @@ use crate::{
///
/// The function name is stored in addition to the body
/// for use in the builtin function `inspect()`
#[derive(Clone, Hash)]
#[derive(Clone, Eq, PartialEq, Hash)]
pub(crate) enum SassFunction {
Builtin(Builtin, Identifier),
UserDefined(Box<Function>, Identifier),
@ -64,20 +64,3 @@ impl fmt::Debug for SassFunction {
.finish()
}
}
impl PartialEq for SassFunction {
fn eq(&self, other: &Self) -> bool {
match self {
Self::UserDefined(f, ..) => match other {
Self::UserDefined(f2, ..) => f == f2,
Self::Builtin(..) => false,
},
Self::Builtin(f, ..) => match other {
Self::UserDefined(..) => false,
Self::Builtin(f2, ..) => f == f2,
},
}
}
}
impl Eq for SassFunction {}