Skip to content

The Fn trait cannot be use by non-method units

Code to reproduce

struct X {}
impl X {
  // This manages to find `Fn`
  fn foo<F: Fn<(bool), bool>>(self) {}
}

// This is unable to find `Fn`
fn foo<F: Fn<(bool), bool>>() {}

Reported error

error: Use of undeclared name Fn
  ┌─ src/main.spade:6:11

6 │ fn foo<F: Fn<(bool), bool>>() {}
  │           ^^ Undeclared name