Merge branch 'bug-fixes'
This commit is contained in:
commit
e191f9d91e
14
CHANGELOG.md
14
CHANGELOG.md
@ -51,6 +51,20 @@ Enhancements
|
|||||||
* `StaticVec` is changed to keep three items inline instead of four.
|
* `StaticVec` is changed to keep three items inline instead of four.
|
||||||
|
|
||||||
|
|
||||||
|
Version 1.0.6
|
||||||
|
=============
|
||||||
|
|
||||||
|
|
||||||
|
Version 1.0.5
|
||||||
|
=============
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
* `FloatWrapper` is no longer erroneously exported under `no_float+internals`.
|
||||||
|
* The `sign` function now works properly for float values that are `NaN`.
|
||||||
|
|
||||||
|
|
||||||
Version 1.0.4
|
Version 1.0.4
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
@ -2,7 +2,10 @@ error[E0277]: the trait bound `NonClonable: Clone` is not satisfied
|
|||||||
--> $DIR/rhai_fn_non_clonable_return.rs:11:8
|
--> $DIR/rhai_fn_non_clonable_return.rs:11:8
|
||||||
|
|
|
|
||||||
11 | pub fn test_fn(input: f32) -> NonClonable {
|
11 | pub fn test_fn(input: f32) -> NonClonable {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonClonable`
|
| ^^^^^^^^^^^^^^^^^^^^^^^-----------
|
||||||
|
| | |
|
||||||
|
| | required by a bound introduced by this call
|
||||||
|
| the trait `Clone` is not implemented for `NonClonable`
|
||||||
|
|
|
|
||||||
note: required by a bound in `rhai::Dynamic::from`
|
note: required by a bound in `rhai::Dynamic::from`
|
||||||
--> $DIR/dynamic.rs:1121:30
|
--> $DIR/dynamic.rs:1121:30
|
||||||
|
@ -2,7 +2,10 @@ error[E0277]: the trait bound `NonClonable: Clone` is not satisfied
|
|||||||
--> $DIR/rhai_mod_non_clonable_return.rs:12:12
|
--> $DIR/rhai_mod_non_clonable_return.rs:12:12
|
||||||
|
|
|
|
||||||
12 | pub fn test_fn(input: f32) -> NonClonable {
|
12 | pub fn test_fn(input: f32) -> NonClonable {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonClonable`
|
| ^^^^^^^^^^^^^^^^^^^^^^^-----------
|
||||||
|
| | |
|
||||||
|
| | required by a bound introduced by this call
|
||||||
|
| the trait `Clone` is not implemented for `NonClonable`
|
||||||
|
|
|
|
||||||
note: required by a bound in `rhai::Dynamic::from`
|
note: required by a bound in `rhai::Dynamic::from`
|
||||||
--> $DIR/dynamic.rs:1121:30
|
--> $DIR/dynamic.rs:1121:30
|
||||||
|
@ -229,10 +229,15 @@ pub use token::{InputStream, Token, TokenizeState, TokenizerControl, TokenizerCo
|
|||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
#[deprecated = "this type is volatile and may change"]
|
#[deprecated = "this type is volatile and may change"]
|
||||||
pub use ast::{
|
pub use ast::{
|
||||||
ASTNode, BinaryExpr, CustomExpr, Expr, FloatWrapper, FnCallExpr, FnCallHashes, Ident,
|
ASTNode, BinaryExpr, CustomExpr, Expr, FnCallExpr, FnCallHashes, Ident, OpAssignment,
|
||||||
OpAssignment, OptionFlags, ScriptFnDef, Stmt, StmtBlock, AST_OPTION_FLAGS::*,
|
OptionFlags, ReturnType, ScriptFnDef, Stmt, StmtBlock, AST_OPTION_FLAGS::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "internals")]
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
#[deprecated = "this type is volatile and may change"]
|
||||||
|
pub use ast::FloatWrapper;
|
||||||
|
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
#[deprecated = "this type is volatile and may change"]
|
#[deprecated = "this type is volatile and may change"]
|
||||||
pub use engine::{EvalState, FnResolutionCache, FnResolutionCacheEntry, Imports};
|
pub use engine::{EvalState, FnResolutionCache, FnResolutionCacheEntry, Imports};
|
||||||
|
@ -163,13 +163,7 @@ macro_rules! gen_signed_functions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn sign(x: $arg_type) -> INT {
|
pub fn sign(x: $arg_type) -> INT {
|
||||||
if x == 0 {
|
x.signum() as INT
|
||||||
0
|
|
||||||
} else if x < 0 {
|
|
||||||
-1
|
|
||||||
} else {
|
|
||||||
1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})* }
|
})* }
|
||||||
@ -249,6 +243,8 @@ gen_signed_functions!(signed_num_128 => i128);
|
|||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
#[export_module]
|
#[export_module]
|
||||||
mod f32_functions {
|
mod f32_functions {
|
||||||
|
use crate::EvalAltResult;
|
||||||
|
|
||||||
#[cfg(not(feature = "f32_float"))]
|
#[cfg(not(feature = "f32_float"))]
|
||||||
pub mod basic_arithmetic {
|
pub mod basic_arithmetic {
|
||||||
#[rhai_fn(name = "+")]
|
#[rhai_fn(name = "+")]
|
||||||
@ -329,13 +325,15 @@ mod f32_functions {
|
|||||||
pub fn abs(x: f32) -> f32 {
|
pub fn abs(x: f32) -> f32 {
|
||||||
x.abs()
|
x.abs()
|
||||||
}
|
}
|
||||||
pub fn sign(x: f32) -> INT {
|
#[rhai_fn(return_raw)]
|
||||||
|
pub fn sign(x: f32) -> Result<INT, Box<EvalAltResult>> {
|
||||||
if x == 0.0 {
|
if x == 0.0 {
|
||||||
0
|
Ok(0)
|
||||||
} else if x < 0.0 {
|
|
||||||
-1
|
|
||||||
} else {
|
} else {
|
||||||
1
|
match x.signum() {
|
||||||
|
x if x.is_nan() => Err(make_err("Sign of NaN is undefined")),
|
||||||
|
x => Ok(x as INT),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn is_zero(x: f32) -> bool {
|
pub fn is_zero(x: f32) -> bool {
|
||||||
@ -437,13 +435,15 @@ mod f64_functions {
|
|||||||
pub fn abs(x: f64) -> f64 {
|
pub fn abs(x: f64) -> f64 {
|
||||||
x.abs()
|
x.abs()
|
||||||
}
|
}
|
||||||
pub fn sign(x: f64) -> INT {
|
#[rhai_fn(return_raw)]
|
||||||
|
pub fn sign(x: f64) -> Result<INT, Box<EvalAltResult>> {
|
||||||
if x == 0.0 {
|
if x == 0.0 {
|
||||||
0
|
Ok(0)
|
||||||
} else if x < 0.0 {
|
|
||||||
-1
|
|
||||||
} else {
|
} else {
|
||||||
1
|
match x.signum() {
|
||||||
|
x if x.is_nan() => Err(make_err("Sign of NaN is undefined")),
|
||||||
|
x => Ok(x as INT),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn is_zero(x: f64) -> bool {
|
pub fn is_zero(x: f64) -> bool {
|
||||||
|
@ -464,6 +464,9 @@ impl<'a> Scope<'a> {
|
|||||||
/// *ptr = 123_i64.into();
|
/// *ptr = 123_i64.into();
|
||||||
///
|
///
|
||||||
/// assert_eq!(my_scope.get_value::<i64>("x").expect("x should exist"), 123);
|
/// assert_eq!(my_scope.get_value::<i64>("x").expect("x should exist"), 123);
|
||||||
|
///
|
||||||
|
/// my_scope.push_constant("Z", 1_i64);
|
||||||
|
/// assert!(my_scope.get_mut("Z").is_none());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
Loading…
Reference in New Issue
Block a user