How to write down the type of a trait function?


I have the following code:

pub enum Lazy<T, F: Fn() -> T> {

impl<T, F: Fn() -> T> Lazy<T, F> {
    pub fn new(init: F) -> Lazy<T, F> {

impl<T: Default> Lazy<T, _> {
    pub fn new_default() -> Lazy<T, _> {

The second impl block is obviously invalid as is (with underscores for type parameters). What I’m trying to do is figure out how to write down the type of <T as Default>::default, which should implement Fn() -> T, and put that type where the underscores are now, but I can’t figure out how to write down its type explicitly.


You can refer to T::default as a plain function, like Lazy<T, fn() -> T>.


Ah cool that worked; thanks!