diff --git a/src/builtins/time/compat.rs b/src/builtins/time/compat.rs index f2af5a8..04feba7 100644 --- a/src/builtins/time/compat.rs +++ b/src/builtins/time/compat.rs @@ -267,7 +267,7 @@ struct GoTimeFormatItems<'a> { } impl GoTimeFormatItems<'_> { - fn parse(reminder: &str) -> GoTimeFormatItems { + fn parse(reminder: &str) -> GoTimeFormatItems<'_> { GoTimeFormatItems { reminder, queue: &[], @@ -275,7 +275,7 @@ impl GoTimeFormatItems<'_> { } } - fn format(reminder: &str) -> GoTimeFormatItems { + fn format(reminder: &str) -> GoTimeFormatItems<'_> { GoTimeFormatItems { reminder, queue: &[], diff --git a/src/builtins/units.rs b/src/builtins/units.rs index 46af0ce..55bbb18 100644 --- a/src/builtins/units.rs +++ b/src/builtins/units.rs @@ -108,7 +108,7 @@ fn parse(span: &Span, params: &[Ref], args: &[Value], _strict: bool) -> Re n.mul_assign(&Number::two_pow(e)?)?; Ok(Value::from(n)) } else { - return Ok(Value::Undefined); + Ok(Value::Undefined) } } diff --git a/src/engine.rs b/src/engine.rs index d7ec5f3..b33aff4 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -23,12 +23,14 @@ pub struct Engine { rego_v1: bool, } +#[cfg(feature = "azure_policy")] #[derive(Debug, Clone, Serialize)] pub struct PolicyPackageNameDefinition { pub source_file: String, pub package_name: String, } +#[cfg(feature = "azure_policy")] #[derive(Debug, Clone, Serialize)] pub struct PolicyParameter { pub name: String, @@ -36,11 +38,13 @@ pub struct PolicyParameter { pub required: bool, } +#[cfg(feature = "azure_policy")] #[derive(Debug, Clone, Serialize)] pub struct PolicyModifier { pub name: String, } +#[cfg(feature = "azure_policy")] #[derive(Debug, Clone, Serialize)] pub struct PolicyParameters { pub source_file: String, @@ -954,7 +958,7 @@ impl Engine { #[cfg_attr(docsrs, doc(cfg(feature = "azure_policy")))] pub fn get_policy_package_names(&self) -> Result> { let mut package_names = vec![]; - for m in &self.modules { + for m in self.modules.iter() { let package_name = Interpreter::get_path_string(&m.package.refr, None)?; package_names.push(PolicyPackageNameDefinition { source_file: m.package.span.source.file().to_string(), @@ -987,7 +991,7 @@ impl Engine { #[cfg_attr(docsrs, doc(cfg(feature = "azure_policy")))] pub fn get_policy_parameters(&self) -> Result> { let mut policy_parameter_definitions = vec![]; - for m in &self.modules { + for m in self.modules.iter() { let mut parameters = vec![]; let mut modifiers = vec![]; diff --git a/src/interpreter.rs b/src/interpreter.rs index cf1abb0..d9a1ed9 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -3696,9 +3696,7 @@ impl Interpreter { MapEntry::Occupied(o) => { if idx + 1 == comps.len() { for (_, i) in o.get() { - if index.is_some() && i.is_some() { - let old = i.as_ref().unwrap(); - let new = index.as_ref().unwrap(); + if let (Some(old), Some(new)) = (i, &index) { if old == new { bail!(refr.span().error("multiple default rules for the variable with the same index")); } diff --git a/src/lexer.rs b/src/lexer.rs index 5888300..e792cb5 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -120,7 +120,7 @@ impl cmp::Eq for SourceStr {} impl cmp::PartialOrd for SourceStr { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.text().cmp(other.text())) + Some(self.cmp(other)) } }