Avoid warnings.
This commit is contained in:
@@ -3,10 +3,11 @@ use crate::def_package;
|
||||
use crate::engine::Engine;
|
||||
use crate::module::{FuncReturn, Module};
|
||||
use crate::parser::{ImmutableString, INT};
|
||||
use crate::result::EvalAltResult;
|
||||
use crate::token::Position;
|
||||
use crate::utils::StaticVec;
|
||||
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
use crate::{result::EvalAltResult, token::Position};
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
use crate::engine::Array;
|
||||
|
||||
@@ -226,15 +227,15 @@ def_package!(crate:MoreStringPackage:"Additional string utilities, including str
|
||||
lib.set_raw_fn(
|
||||
"pad",
|
||||
&[TypeId::of::<ImmutableString>(), TypeId::of::<INT>(), TypeId::of::<char>()],
|
||||
|engine: &Engine, _: &Module, args: &mut [&mut Dynamic]| {
|
||||
|_engine: &Engine, _: &Module, args: &mut [&mut Dynamic]| {
|
||||
let len = *args[1].downcast_ref::< INT>().unwrap();
|
||||
|
||||
// Check if string will be over max size limit
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
if engine.max_string_size > 0 && len > 0 && (len as usize) > engine.max_string_size {
|
||||
if _engine.limits.max_string_size > 0 && len > 0 && (len as usize) > _engine.limits.max_string_size {
|
||||
return Err(Box::new(EvalAltResult::ErrorDataTooLarge(
|
||||
"Length of string".to_string(),
|
||||
engine.max_string_size,
|
||||
_engine.limits.max_string_size,
|
||||
len as usize,
|
||||
Position::none(),
|
||||
)));
|
||||
@@ -253,10 +254,11 @@ def_package!(crate:MoreStringPackage:"Additional string utilities, including str
|
||||
p.push(ch);
|
||||
}
|
||||
|
||||
if engine.max_string_size > 0 && s.len() > engine.max_string_size {
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
if _engine.limits.max_string_size > 0 && s.len() > _engine.limits.max_string_size {
|
||||
return Err(Box::new(EvalAltResult::ErrorDataTooLarge(
|
||||
"Length of string".to_string(),
|
||||
engine.max_string_size,
|
||||
_engine.limits.max_string_size,
|
||||
s.len(),
|
||||
Position::none(),
|
||||
)));
|
||||
|
Reference in New Issue
Block a user