Skip to content

Commit

Permalink
Merge pull request #643 from rben01/ffi-unbox-function
Browse files Browse the repository at this point in the history
Replaced `Box<dyn Fn(Args) -> ...>` with `fn(Args) -> ...` in ffi functions
  • Loading branch information
sharkdp authored Nov 3, 2024
2 parents 59a9f74 + 0f7930e commit 8470407
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion numbat/src/ffi/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(crate) fn functions() -> &'static HashMap<String, ForeignFunction> {
ForeignFunction {
name: $fn_name,
arity: $arity,
callable: Callable::Function(Box::new($callable)),
callable: Callable::Function($callable),
},
);
};
Expand Down
4 changes: 1 addition & 3 deletions numbat/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ type Result<T> = std::result::Result<T, Box<RuntimeError>>;

pub(crate) type Args = VecDeque<Value>;

type BoxedFunction = Box<dyn Fn(Args) -> Result<Value> + Send + Sync>;

pub(crate) enum Callable {
Function(BoxedFunction),
Function(fn(Args) -> Result<Value>),
Procedure(fn(&mut ExecutionContext, Args, Vec<Span>) -> ControlFlow),
}

Expand Down

0 comments on commit 8470407

Please sign in to comment.