core: reduce code duplication in codegen/builtin_fns #422

Merged
sb10q merged 7 commits from refactor-builtin-fns into master 2024-06-20 12:48:45 +08:00
Showing only changes of commit c20c9a2c5a - Show all commits

View File

@ -1050,7 +1050,8 @@ pub fn call_numpy_maximum<'ctx, G: CodeGenerator + ?Sized>(
/// * `fn_name`: The name of the function, only used when throwing an error with [`unsupported_type`]
/// * `get_ret_elem_type`: A function that takes in the input element [`Type`], and returns the correct return [`Type`].
/// Return a constant [`Type`] here if the return type does not depend on the input type.
/// * `on_elem`: The function to be called when the input argument is not an ndarray.
/// * `on_elem`: The function to be called when the input argument is not an ndarray. Returns [`Option::None`]
/// if the element type & value are faulty and should panic with [`unsupported_type`].
fn helper_call_numpy<'ctx, OnElemFn, RetElemFn, G: CodeGenerator + ?Sized>(
generator: &mut G,
derppening marked this conversation as resolved Outdated
  • Move the bounds for G into the where clause.
  • call_numpy makes it seem like you can call any numpy function. Perhaps something like call_numpy_unaryfunc?
- Move the bounds for `G` into the `where` clause. - `call_numpy` makes it seem like you can call any numpy function. Perhaps something like `call_numpy_unaryfunc`?
ctx: &mut CodeGenContext<'ctx, '_>,