In rust, you can declare variables equal to functions. The syntax is let variable_name: fn(function parameters)->return_type = function_name;
You can then use the variable by calling the variable_name(parameters). The code to the left showcases this.
In rust, you can also declare a function parameter as a function.
There are two main ways to do this. Here, I will showcase the way rust recommends, but its syntax is quite different from how you would do it in C or Python.
The syntax is fn function_name<F>(parameter_name:F). Here F is a generic type that corresponds to functions. Then, in the function, you use the where keyword, where the function logic is defined. In the where scope, you define the parameter_name(the function's parameters and return types), and then define what the function does with the function_parameter(in my case, I call it passing in 5 and 3 and then adding them together)
You can then call the function by function_name(parameters);
The second way of defining functions as parameters is more similar to other programming languages.
The syntax is as follows: fn(parameters(define function parameters) ->return type of function_paramters) -> return type of outer function.{function logic}.
To call the function, simply call the function, and pass in a function that aligns with the parameters defined in the original function definition.