Currently I'm learning closures of rust. Here's an example code:
struct Cacher<T>
where
T: Fn(u32) -> u32,
{
calculation: T,
value: Option<u32>,
}
What I don't quite understand is the type annotation syntax in the above where clause.
So, rust doesn't have a "function type", and it uses Fn trait family for the same purpose. I understand this, but the syntax explanation is still missing as far as I know.
I tried running this command in my terminal rustup doc core::ops::Fn, and found the below sentence(not an explanation I'm looking for though) like this:
Also of note is the special syntax for
Fntraits (e.g.Fn(usize, bool) -> usize). Those interested in the technical details of this can refer to the relevant section in the Rustonomicon.
I also followed the link to Rustonomicon, but I couldn't find something like a definition of this syntax.
Can someone help me to understand this? (Or the rust documentation is missing this simple explanation?)