Home > Mobile >  Check if a function takes specified arguments in Rust
Check if a function takes specified arguments in Rust

Time:10-15

Is there a way in a where clause in Rust to check if a function passed as a parameter takes specified arguments?

CodePudding user response:

If you're defining a function that takes a function argument, that argument has a very specific type associated with it that dictates the arguments. You cannot call that function with something that doesn't match, it just won't compile.

If you're thinking in terms of dynamic languages where the arguments are somewhat subjective, you're assuming you can make a mistake here and call it incorrectly. You can't. It's strictly disallowed.

  • Related