Refactor use.

This commit is contained in:
Stephen Chung
2020-11-16 23:10:14 +08:00
parent d50d48f26f
commit 272c8505b8
39 changed files with 226 additions and 372 deletions

View File

@@ -1,10 +1,8 @@
#![allow(non_snake_case)]
use crate::def_package;
use crate::plugin::*;
use crate::INT;
use crate::{result::EvalAltResult, token::NO_POS};
use crate::stdlib::{format, string::String};
use crate::{def_package, EvalAltResult, INT, NO_POS};
#[cfg(not(feature = "no_float"))]
use crate::FLOAT;
@@ -13,8 +11,6 @@ use crate::FLOAT;
#[cfg(not(feature = "no_float"))]
use num_traits::float::Float;
use crate::stdlib::{format, string::String};
#[inline(always)]
pub fn make_err(msg: impl Into<String>) -> Box<EvalAltResult> {
EvalAltResult::ErrorArithmetic(msg.into(), NO_POS).into()

View File

@@ -1,21 +1,17 @@
#![cfg(not(feature = "no_index"))]
#![allow(non_snake_case)]
use crate::def_package;
use crate::dynamic::Dynamic;
use crate::engine::{OP_EQUALS, TYPICAL_ARRAY_SIZE};
use crate::fn_native::{FnPtr, NativeCallContext};
use crate::plugin::*;
use crate::result::EvalAltResult;
use crate::token::NO_POS;
use crate::utils::ImmutableString;
use crate::{Array, INT};
use crate::stdlib::{any::TypeId, boxed::Box, cmp::max, cmp::Ordering, string::ToString};
use crate::{
def_package, Array, Dynamic, EvalAltResult, FnPtr, ImmutableString, NativeCallContext, INT,
NO_POS,
};
#[cfg(not(feature = "no_object"))]
use crate::Map;
use crate::stdlib::{any::TypeId, boxed::Box, cmp::max, cmp::Ordering, string::ToString};
pub type Unit = ();
macro_rules! gen_array_functions {

View File

@@ -1,8 +1,5 @@
use crate::def_package;
use crate::dynamic::Dynamic;
use crate::plugin::*;
use crate::result::EvalAltResult;
use crate::utils::ImmutableString;
use crate::{def_package, Dynamic, EvalAltResult, ImmutableString};
def_package!(crate:EvalPackage:"Disable 'eval'.", lib, {
combine_with_exported_module!(lib, "eval", eval_override);

View File

@@ -1,6 +1,5 @@
use crate::def_package;
use crate::fn_native::FnPtr;
use crate::plugin::*;
use crate::{def_package, FnPtr};
def_package!(crate:BasicFnPackage:"Basic Fn functions.", lib, {
combine_with_exported_module!(lib, "FnPtr", fn_ptr_functions);

View File

@@ -1,12 +1,9 @@
use crate::def_package;
use crate::dynamic::Variant;
use crate::result::EvalAltResult;
use crate::INT;
use crate::stdlib::{
boxed::Box,
ops::{Add, Range},
};
use crate::{def_package, EvalAltResult, INT};
fn get_range<T: Variant + Clone>(from: T, to: T) -> Result<Range<T>, Box<EvalAltResult>> {
Ok(from..to)

View File

@@ -1,11 +1,8 @@
#![cfg(not(feature = "no_object"))]
use crate::def_package;
use crate::dynamic::Dynamic;
use crate::engine::OP_EQUALS;
use crate::plugin::*;
use crate::utils::ImmutableString;
use crate::{Map, INT};
use crate::{def_package, Dynamic, ImmutableString, Map, INT};
#[cfg(not(feature = "no_index"))]
use crate::Array;

View File

@@ -1,9 +1,7 @@
#![allow(non_snake_case)]
use crate::def_package;
use crate::plugin::*;
use crate::token::NO_POS;
use crate::INT;
use crate::{def_package, INT, NO_POS};
#[cfg(not(feature = "no_float"))]
use crate::FLOAT;

View File

@@ -1,10 +1,8 @@
//! Module containing all built-in _packages_ available to Rhai, plus facilities to define custom packages.
use crate::fn_native::{CallableFunction, IteratorFn, Shared};
use crate::module::Module;
use crate::StaticVec;
use crate::fn_native::{CallableFunction, IteratorFn};
use crate::stdlib::any::TypeId;
use crate::{Module, Shared, StaticVec};
pub(crate) mod arithmetic;
mod array_basic;

View File

@@ -1,11 +1,13 @@
#![allow(non_snake_case)]
use crate::def_package;
use crate::engine::{FN_TO_STRING, KEYWORD_DEBUG, KEYWORD_PRINT};
use crate::fn_native::FnPtr;
use crate::plugin::*;
use crate::utils::ImmutableString;
use crate::INT;
use crate::stdlib::{
fmt::{Debug, Display},
format,
string::ToString,
};
use crate::{def_package, FnPtr, ImmutableString, INT};
#[cfg(not(feature = "no_index"))]
use crate::Array;
@@ -13,12 +15,6 @@ use crate::Array;
#[cfg(not(feature = "no_object"))]
use crate::Map;
use crate::stdlib::{
fmt::{Debug, Display},
format,
string::ToString,
};
type Unit = ();
macro_rules! gen_functions {

View File

@@ -1,16 +1,10 @@
#![allow(non_snake_case)]
use crate::def_package;
use crate::dynamic::Dynamic;
use crate::fn_native::FnPtr;
use crate::plugin::*;
use crate::utils::ImmutableString;
use crate::StaticVec;
use crate::INT;
use crate::stdlib::{
any::TypeId, boxed::Box, format, mem, string::String, string::ToString, vec::Vec,
};
use crate::{def_package, Dynamic, FnPtr, ImmutableString, StaticVec, INT};
macro_rules! gen_concat_functions {
($root:ident => $($arg_type:ident),+ ) => {

View File

@@ -1,18 +1,13 @@
#![cfg(not(feature = "no_std"))]
use super::{arithmetic::make_err as make_arithmetic_err, math_basic::MAX_INT};
use crate::def_package;
use crate::dynamic::Dynamic;
use crate::plugin::*;
use crate::result::EvalAltResult;
use crate::INT;
use crate::stdlib::boxed::Box;
use crate::{def_package, Dynamic, EvalAltResult, INT};
#[cfg(not(feature = "no_float"))]
use crate::FLOAT;
use crate::stdlib::boxed::Box;
#[cfg(not(target_arch = "wasm32"))]
use crate::stdlib::time::{Duration, Instant};