diff --git a/src/api/type_names.rs b/src/api/type_names.rs index de6961c1..5717b7cc 100644 --- a/src/api/type_names.rs +++ b/src/api/type_names.rs @@ -102,8 +102,8 @@ fn map_std_type_name(name: &str, shorthands: bool) -> &str { }; } - if name.starts_with("rhai::") { - map_std_type_name(&name[6..], shorthands) + if let Some(stripped) = name.strip_prefix("rhai::") { + map_std_type_name(stripped, shorthands) } else { name } diff --git a/src/ast/ast.rs b/src/ast/ast.rs index e7dcddf9..8a033e2d 100644 --- a/src/ast/ast.rs +++ b/src/ast/ast.rs @@ -793,11 +793,8 @@ impl AST { || !options.contains(ASTFlags::CONSTANT) && include_variables => { let (name, expr, ..) = &**x; - if let Some(value) = expr.get_literal_value() { - Some((name.as_str(), options.contains(ASTFlags::CONSTANT), value)) - } else { - None - } + expr.get_literal_value() + .map(|value| (name.as_str(), options.contains(ASTFlags::CONSTANT), value)) } _ => None, }) diff --git a/src/ast/stmt.rs b/src/ast/stmt.rs index e654ebf3..842c476c 100644 --- a/src/ast/stmt.rs +++ b/src/ast/stmt.rs @@ -486,8 +486,7 @@ impl<'a> IntoIterator for &'a StmtBlock { #[inline(always)] fn into_iter(self) -> Self::IntoIter { - let x = self.block.iter(); - x + self.block.iter() } } diff --git a/src/eval/expr.rs b/src/eval/expr.rs index f4929f19..2980760e 100644 --- a/src/eval/expr.rs +++ b/src/eval/expr.rs @@ -518,6 +518,6 @@ impl Engine { #[cfg(feature = "debugging")] global.debugger.reset_status(reset_debugger); - return result; + result } } diff --git a/src/eval/stmt.rs b/src/eval/stmt.rs index 669db72c..3c7eaf41 100644 --- a/src/eval/stmt.rs +++ b/src/eval/stmt.rs @@ -1045,6 +1045,6 @@ impl Engine { #[cfg(feature = "debugging")] global.debugger.reset_status(reset_debugger); - return result; + result } } diff --git a/src/types/scope.rs b/src/types/scope.rs index aaa76fa3..41e40afe 100644 --- a/src/types/scope.rs +++ b/src/types/scope.rs @@ -81,9 +81,9 @@ impl fmt::Display for Scope<'_> { #[cfg(feature = "no_closure")] let value_is_shared = ""; - write!( + writeln!( f, - "[{}] {}{}{} = {:?}\n", + "[{}] {}{}{} = {:?}", i + 1, if constant { "const " } else { "" }, name,