Is it possible to implement a trait for a specific function and not all T
that implements Fn
. Something like this:
trait Function {}
fn a(x: i32) {}
impl Function for fn(i32) {}
fn func<F: Function>(f: F) {}
fn main() {
func(a);
}
This fails with:
error[E0277]: the trait bound `fn(i32) {a}: Function` is not satisfied
--> examples/experiment.rs:9:10
|
9 | func(a);
| ---- ^ the trait `Function` is not implemented for `fn(i32) {a}`
| |
| required by a bound introduced by this call
|
= help: the following implementations were found:
<fn(i32) as Function>
But trying to do:
impl Function for fn(i32) {a} {}
is also incorrect.