Skip to content

Commit

Permalink
move BinOp to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgurakgun committed Nov 22, 2023
1 parent eafaa27 commit 718d1bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions conjure_oxide/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ fn parse_int_domain(v: &JsonValue) -> Result<Domain> {
Ok(Domain::IntDomain(ranges))
}

// this needs an explicit type signature to force the closures to have the same type
type BinOp = Box<dyn Fn(Box<Expression>, Box<Expression>) -> Expression>;

fn parse_expression(obj: &JsonValue) -> Option<Expression> {
// this needs an explicit type signature to force the closures to have the same type
type BinOp = Box<dyn Fn(Box<Expression>, Box<Expression>) -> Expression>;
let binary_operators: HashMap<&str, BinOp> = [
("MkOpEq", Box::new(Expression::Eq) as Box<dyn Fn(_, _) -> _>),
(
Expand Down Expand Up @@ -187,7 +188,7 @@ fn parse_sum(op_sum: &serde_json::Map<String, Value>) -> Option<Expression> {

fn parse_bin_op(
bin_op: &serde_json::Map<String, Value>,
binary_operators: HashMap<&str, Box<dyn Fn(Box<Expression>, Box<Expression>) -> Expression>>,
binary_operators: HashMap<&str, BinOp>,
) -> Option<Expression> {
// we know there is a single key value pair in this object
// extract the value, ignore the key
Expand Down

0 comments on commit 718d1bc

Please sign in to comment.