Skip to content

Commit

Permalink
Satisfy clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
schungx committed Sep 6, 2023
1 parent 9f6d5ae commit 5acd18c
Show file tree
Hide file tree
Showing 25 changed files with 515 additions and 471 deletions.
17 changes: 17 additions & 0 deletions src/func/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,25 @@ pub fn get_builtin_binary_op_fn(op: &Token, x: &Dynamic, y: &Dynamic) -> Option<
Divide => impl_op!(FLOAT => $xx / $yy),
Modulo => impl_op!(FLOAT => $xx % $yy),
PowerOf => impl_op!(FLOAT => $xx.powf($yy as FLOAT)),

#[cfg(feature = "unchecked")]
EqualsTo => impl_op!(FLOAT => $xx == $yy),
#[cfg(not(feature = "unchecked"))]
EqualsTo => Some((|_, args| {
let x = args[0].$xx().unwrap() as FLOAT;
let y = args[1].$yy().unwrap() as FLOAT;
Ok(((x - y).abs() <= FLOAT::EPSILON).into())
}, false)),

#[cfg(feature = "unchecked")]
NotEqualsTo => impl_op!(FLOAT => $xx != $yy),
#[cfg(not(feature = "unchecked"))]
NotEqualsTo => Some((|_, args| {
let x = args[0].$xx().unwrap() as FLOAT;
let y = args[1].$yy().unwrap() as FLOAT;
Ok(((x - y).abs() > FLOAT::EPSILON).into())
}, false)),

GreaterThan => impl_op!(FLOAT => $xx > $yy),
GreaterThanEqualsTo => impl_op!(FLOAT => $xx >= $yy),
LessThan => impl_op!(FLOAT => $xx < $yy),
Expand Down
175 changes: 99 additions & 76 deletions src/func/call.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/func/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ impl<'a> NativeCallContext<'a> {
result.try_cast_raw().map_err(|r| {
let result_type = self.engine().map_type_name(r.type_name());
let cast_type = match type_name::<T>() {
typ @ _ if typ.contains("::") => self.engine.map_type_name(typ),
typ @ _ => typ,
typ if typ.contains("::") => self.engine.map_type_name(typ),
typ => typ,
};
ERR::ErrorMismatchOutputType(
cast_type.into(),
Expand Down Expand Up @@ -349,8 +349,8 @@ impl<'a> NativeCallContext<'a> {
result.try_cast_raw().map_err(|r| {
let result_type = self.engine().map_type_name(r.type_name());
let cast_type = match type_name::<T>() {
typ @ _ if typ.contains("::") => self.engine.map_type_name(typ),
typ @ _ => typ,
typ if typ.contains("::") => self.engine.map_type_name(typ),
typ => typ,
};
ERR::ErrorMismatchOutputType(
cast_type.into(),
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
// #![warn(clippy::pedantic)]
// #![warn(clippy::nursery)]
#![warn(clippy::cargo)]
// #![warn(clippy::undocumented_unsafe_blocks)]
#![warn(clippy::undocumented_unsafe_blocks)]
#![allow(clippy::unit_arg)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_panics_doc)]
Expand All @@ -80,6 +80,7 @@
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::match_same_arms)]
// The lints below can be turned off to reduce signal/noise ratio
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::too_many_lines)]
#![allow(let_underscore_drop)]
#![allow(clippy::absurd_extreme_comparisons)]
Expand Down
Loading

0 comments on commit 5acd18c

Please sign in to comment.