Lefevre Victor
Lefevre Victor

Reputation: 33

Check if a function takes specified arguments in Rust

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

Upvotes: 1

Views: 270

Answers (1)

tadman
tadman

Reputation: 211740

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.

Upvotes: 2

Related Questions