Skip to content

Bitwise && logical operations #14

@hanusek

Description

@hanusek

Hello!
I have two problems with expressions.

  1. Library did not recognize booleans.
  2. The function - ez_eval() returns an incorrect value.
    The correct value is 2.

@lnicola @likebike Can you help me?

use fasteval::{EmptyNamespace, ez_eval};

let mut ns = EmptyNamespace;
        
// OK
let value = ez_eval("1 == 1", &mut ns).unwrap();
println!("1 == 1 -> fast_eval: {:?}", value);
assert_eq!(value, 1.0);
       
// 1.
// PROBLEM
let value = ez_eval("true == true", &mut ns).unwrap();
println!("true == true -> fast_eval: {:?}", value);
assert_eq!(value, 1.0);
        
// 2.
// PROBLEM, result = 3 ??
let bitand_text = format!("{} && {}",  b_value, b_mask);
let value = ez_eval(bitand_text.as_str(), &mut ns).unwrap();
println!("bitand_text {} -> fast_eval: {:?}", bitand_text, value);
assert_eq!(value, 2.0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions