Fix builds.

This commit is contained in:
Stephen Chung 2021-07-04 16:51:05 +08:00
parent 694ac5b5bd
commit 4adc044c79
3 changed files with 48 additions and 37 deletions

View File

@ -508,6 +508,8 @@ impl Hash for Dynamic {
Union::Int(ref i, _, _) => i.hash(state),
#[cfg(not(feature = "no_float"))]
Union::Float(ref f, _, _) => f.hash(state),
#[cfg(feature = "decimal")]
Union::Decimal(ref d, _, _) => d.hash(state),
#[cfg(not(feature = "no_index"))]
Union::Array(ref a, _, _) => a.as_ref().hash(state),
#[cfg(not(feature = "no_object"))]
@ -522,10 +524,11 @@ impl Hash for Dynamic {
#[cfg(feature = "sync")]
Union::Shared(ref cell, _, _) => (*cell.read().unwrap()).hash(state),
Union::Variant(ref _value, _, _) => {
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
Union::Variant(ref value, _, _) => {
let value_any = (***value).as_any();
{
let value_any = (***_value).as_any();
let type_id = value_any.type_id();
if type_id == TypeId::of::<u8>() {
@ -564,6 +567,9 @@ impl Hash for Dynamic {
}
}
unimplemented!("a custom type cannot be hashed")
}
#[cfg(not(feature = "no_std"))]
Union::TimeStamp(_, _, _) => unimplemented!("{} cannot be hashed", self.type_name()),
}

View File

@ -669,6 +669,7 @@ impl EvalState {
scope_level: 0,
operations: 0,
modules: 0,
#[cfg(not(feature = "no_module"))]
resolver: None,
fn_resolution_caches: Vec::new(),
}

View File

@ -173,6 +173,10 @@ mod number_formatting {
pub fn int_to_octal(value: INT) -> ImmutableString {
to_octal(value)
}
#[rhai_fn(name = "to_binary")]
pub fn int_to_binary(value: INT) -> ImmutableString {
to_binary(value)
}
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]