Comment by tuetuopay
25 days ago
You most definitely can.
fn foo<F, T>(f: F)
where
F: Fn(T),
T: ToString,
{
f("Hello World")
}
Or did I not understand what you meant?
25 days ago
You most definitely can.
fn foo<F, T>(f: F)
where
F: Fn(T),
T: ToString,
{
f("Hello World")
}
Or did I not understand what you meant?
Something like this isn’t possible
The workaround:
Ha, yes, I see what you mean now. That's not really the closure's fault but monomorphization of the foo function. The specific thing you want to do would require boxing the value, or do more involved typing.