Code style edits.

This commit is contained in:
Stephen Chung
2021-03-16 18:16:40 +08:00
parent 082ecaa739
commit 5172ade179
4 changed files with 101 additions and 110 deletions

View File

@@ -29,7 +29,7 @@ where
#[cfg(not(feature = "unchecked"))]
if let Some(r) = from.checked_add(&step) {
if r == from {
return Err(Box::new(EvalAltResult::ErrorInFunctionCall(
return EvalAltResult::ErrorInFunctionCall(
"range".to_string(),
"".to_string(),
Box::new(EvalAltResult::ErrorArithmetic(
@@ -37,7 +37,8 @@ where
crate::Position::NONE,
)),
crate::Position::NONE,
)));
)
.into();
}
}
@@ -204,10 +205,10 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
if step.is_zero() {
use crate::stdlib::string::ToString;
return Err(Box::new(EvalAltResult::ErrorInFunctionCall("range".to_string(), "".to_string(),
return EvalAltResult::ErrorInFunctionCall("range".to_string(), "".to_string(),
Box::new(EvalAltResult::ErrorArithmetic("step value cannot be zero".to_string(), crate::Position::NONE)),
crate::Position::NONE,
)));
).into();
}
Ok(Self(from, to, step))
@@ -246,6 +247,8 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
}
}
impl crate::stdlib::iter::FusedIterator for StepDecimalRange {}
lib.set_iterator::<StepDecimalRange>();
let hash = lib.set_native_fn("range", |from, to| StepDecimalRange::new(from, to, Decimal::one()));