diff --git a/src/any.rs b/src/any.rs index c2003da4..96fe099b 100644 --- a/src/any.rs +++ b/src/any.rs @@ -1,7 +1,9 @@ //! Helper module which defines the `Any` trait to to allow dynamic value handling. -use std::any::{type_name, TypeId}; -use std::fmt; +use std::{ + any::{type_name, TypeId}, + fmt, +}; /// An raw value of any type. pub type Variant = dyn Any; diff --git a/src/api.rs b/src/api.rs index ca6fe88f..5e89c5ca 100644 --- a/src/api.rs +++ b/src/api.rs @@ -8,8 +8,12 @@ use crate::fn_register::RegisterFn; use crate::parser::{lex, parse, Position, AST}; use crate::result::EvalAltResult; use crate::scope::Scope; -use std::any::{type_name, TypeId}; -use std::sync::Arc; +use std::{ + any::{type_name, TypeId}, + fs::File, + io::prelude::*, + sync::Arc, +}; impl<'e> Engine<'e> { pub(crate) fn register_fn_raw( @@ -102,9 +106,6 @@ impl<'e> Engine<'e> { /// Compile a file into an AST. pub fn compile_file(&self, filename: &str) -> Result { - use std::fs::File; - use std::io::prelude::*; - let mut f = File::open(filename) .map_err(|err| EvalAltResult::ErrorReadingScriptFile(filename.into(), err))?; @@ -117,9 +118,6 @@ impl<'e> Engine<'e> { /// Evaluate a file. pub fn eval_file(&mut self, filename: &str) -> Result { - use std::fs::File; - use std::io::prelude::*; - let mut f = File::open(filename) .map_err(|err| EvalAltResult::ErrorReadingScriptFile(filename.into(), err))?; @@ -208,9 +206,6 @@ impl<'e> Engine<'e> { /// Evaluate a file, but throw away the result and only return error (if any). /// Useful for when you don't need the result, but still need to keep track of possible errors. pub fn consume_file(&mut self, filename: &str) -> Result<(), EvalAltResult> { - use std::fs::File; - use std::io::prelude::*; - let mut f = File::open(filename) .map_err(|err| EvalAltResult::ErrorReadingScriptFile(filename.into(), err))?; diff --git a/src/builtin.rs b/src/builtin.rs index 546d680f..6cce507e 100644 --- a/src/builtin.rs +++ b/src/builtin.rs @@ -4,9 +4,12 @@ use crate::any::Any; use crate::engine::{Array, Engine}; use crate::fn_register::RegisterFn; -use std::fmt::{Debug, Display}; -use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Range, Rem, Sub}; -use std::{i32, i64, u32}; +use std::{ + fmt::{Debug, Display}, + i32, i64, + ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Range, Rem, Sub}, + u32, +}; #[cfg(feature = "unchecked")] use std::ops::{Shl, Shr}; diff --git a/src/engine.rs b/src/engine.rs index 5806abb2..89dac01c 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -4,12 +4,14 @@ use crate::any::{Any, AnyExt, Dynamic, Variant}; use crate::parser::{Expr, FnDef, Position, Stmt}; use crate::result::EvalAltResult; use crate::scope::Scope; -use std::any::{type_name, TypeId}; -use std::borrow::Cow; -use std::cmp::{PartialEq, PartialOrd}; -use std::collections::HashMap; -use std::iter::once; -use std::sync::Arc; +use std::{ + any::{type_name, TypeId}, + borrow::Cow, + cmp::{PartialEq, PartialOrd}, + collections::HashMap, + iter::once, + sync::Arc, +}; /// An dynamic array of `Dynamic` values. pub type Array = Vec;