diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-20 14:14:13 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-20 14:21:59 +0100 |
| commit | b73b4f33bcf0e4ff2cfa8438433205cd3a323e43 (patch) | |
| tree | b59ee2c6f46558b7e6a0b2b50e0f7e93afeb3ace /src/model | |
| parent | dd331f007cb9c9968605f8d3eaef8fb498c21322 (diff) | |
Fix a few clippy lints
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/array.rs | 2 | ||||
| -rw-r--r-- | src/model/eval.rs | 6 | ||||
| -rw-r--r-- | src/model/realize.rs | 8 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/model/array.rs b/src/model/array.rs index 28b9d1a0..0071d4f4 100644 --- a/src/model/array.rs +++ b/src/model/array.rs @@ -183,7 +183,7 @@ impl Array { /// Transform each item in the array with a function. pub fn map(&self, vm: &Vm, func: Func) -> SourceResult<Self> { - if func.argc().map_or(false, |count| count < 1 || count > 2) { + if func.argc().map_or(false, |count| !(1..=2).contains(&count)) { bail!(func.span(), "function must have one or two parameters"); } let enumerate = func.argc() == Some(2); diff --git a/src/model/eval.rs b/src/model/eval.rs index 0469649b..b037a1bd 100644 --- a/src/model/eval.rs +++ b/src/model/eval.rs @@ -567,7 +567,7 @@ impl Eval for ast::Ident { impl ast::Ident { fn eval_in_math(&self, vm: &mut Vm) -> SourceResult<Content> { if self.as_untyped().len() == self.len() - && matches!(vm.scopes.get(&self), Ok(Value::Func(_)) | Err(_)) + && matches!(vm.scopes.get(self), Ok(Value::Func(_)) | Err(_)) { Ok((vm.items.symbol)(EcoString::from(self.get()) + ":op".into())) } else { @@ -635,7 +635,7 @@ impl Eval for ast::Str { type Output = Value; fn eval(&self, _: &mut Vm) -> SourceResult<Self::Output> { - Ok(Value::Str(self.get().clone().into())) + Ok(Value::Str(self.get().into())) } } @@ -1245,7 +1245,7 @@ impl Eval for ast::ModuleImport { errors.push(error!(ident.span(), "unresolved import")); } } - if errors.len() > 0 { + if !errors.is_empty() { return Err(Box::new(errors)); } } diff --git a/src/model/realize.rs b/src/model/realize.rs index 39c1fd42..b33cc0bb 100644 --- a/src/model/realize.rs +++ b/src/model/realize.rs @@ -39,7 +39,7 @@ pub fn realize( for recipe in styles.recipes() { let guard = Guard::Nth(n); if recipe.applicable(target) && !target.is_guarded(guard) { - if let Some(content) = try_apply(vt, &target, recipe, guard)? { + if let Some(content) = try_apply(vt, target, recipe, guard)? { realized = Some(content); break; } @@ -92,13 +92,13 @@ fn try_apply( } Some(Selector::Regex(regex)) => { - let Some(text) = item!(text_str)(&target) else { + let Some(text) = item!(text_str)(target) else { return Ok(None); }; let make = |s| { let mut content = item!(text)(s); - content.copy_modifiers(&target); + content.copy_modifiers(target); content }; @@ -166,7 +166,7 @@ pub trait Finalize { } /// Guards content against being affected by the same show rule multiple times. -#[derive(Debug, Copy, Clone, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Guard { /// The nth recipe from the top of the chain. Nth(usize), |
