In Rust, what is `fn() -> ()`?

后端 未结 3 1917
灰色年华
灰色年华 2021-01-19 22:04

I have a grasp of the Fn (capital-F) traits: Fn, FnMut, FnOnce. I understand that they are traits and work like traits.

But wha

3条回答
  •  囚心锁ツ
    2021-01-19 22:38

    It is a function pointer type.

    It refers only to a function, not a closure, since it contains just the address of the function not the captured environment a closure needs.

    A Fn trait (capital F) can refer either to a closure or a function.

提交回复
热议问题