Fix compiling for all features.

This commit is contained in:
Stephen Chung 2020-04-28 19:39:28 +08:00
parent d3a97dc86b
commit 6351c07bc6
5 changed files with 8 additions and 9 deletions

View File

@ -12,12 +12,10 @@ use crate::stdlib::{
}; };
fn map_get_keys(map: &mut Map) -> Vec<Dynamic> { fn map_get_keys(map: &mut Map) -> Vec<Dynamic> {
map.iter() map.iter().map(|(k, _)| k.to_string().into()).collect()
.map(|(k, _)| k.to_string().into())
.collect::<Vec<_>>()
} }
fn map_get_values(map: &mut Map) -> Vec<Dynamic> { fn map_get_values(map: &mut Map) -> Vec<Dynamic> {
map.iter().map(|(_, v)| v.clone()).collect::<Vec<_>>() map.iter().map(|(_, v)| v.clone()).collect()
} }
#[cfg(not(feature = "no_object"))] #[cfg(not(feature = "no_object"))]

View File

@ -37,7 +37,7 @@ fn sub_string(s: &mut String, start: INT, len: INT) -> String {
len as usize len as usize
}; };
chars[offset..][..len].into_iter().collect::<String>() chars[offset..][..len].into_iter().collect()
} }
fn crop_string(s: &mut String, start: INT, len: INT) { fn crop_string(s: &mut String, start: INT, len: INT) {
let offset = if s.is_empty() || len <= 0 { let offset = if s.is_empty() || len <= 0 {

View File

@ -87,10 +87,10 @@ def_package!(crate:BasicTimePackage:"Basic timing utilities.", lib, {
#[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "unchecked"))]
{ {
if seconds > (MAX_INT as u64) { if seconds > (MAX_INT as u64) {
return Err(EvalAltResult::ErrorArithmetic( return Err(Box::new(EvalAltResult::ErrorArithmetic(
format!("Integer overflow for timestamp.elapsed(): {}", seconds), format!("Integer overflow for timestamp.elapsed(): {}", seconds),
Position::none(), Position::none(),
)); )));
} }
} }
return Ok(seconds as INT); return Ok(seconds as INT);

View File

@ -4,7 +4,7 @@ use crate::any::{Dynamic, Variant};
use crate::parser::{map_dynamic_to_expr, Expr}; use crate::parser::{map_dynamic_to_expr, Expr};
use crate::token::Position; use crate::token::Position;
use crate::stdlib::{borrow::Cow, iter, vec::Vec}; use crate::stdlib::{borrow::Cow, boxed::Box, iter, vec::Vec};
/// Type of an entry in the Scope. /// Type of an entry in the Scope.
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)] #[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
@ -362,7 +362,7 @@ impl<'a> Scope<'a> {
} }
/// Get an iterator to entries in the Scope. /// Get an iterator to entries in the Scope.
pub fn iter(&self) -> impl Iterator<Item = &Entry> { pub(crate) fn iter(&self) -> impl Iterator<Item = &Entry> {
self.0.iter().rev() // Always search a Scope in reverse order self.0.iter().rev() // Always search a Scope in reverse order
} }
} }

View File

@ -143,6 +143,7 @@ fn test_map_return() -> Result<(), Box<EvalAltResult>> {
} }
#[test] #[test]
#[cfg(not(feature = "no_index"))]
fn test_map_for() -> Result<(), Box<EvalAltResult>> { fn test_map_for() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new(); let engine = Engine::new();