You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structMessage<'a>{data:&'a u32,}structHandler<T>(Option<Box<Fn(T)>>);structCfg{
handler:for<'a> Handler<Message<'a>>,// error: `Handler` is not a trait [E0404]}
This precludes a lot of useful patterns.
The text was updated successfully, but these errors were encountered:
What you've written isn't really what you want... what you want is something more like:
structMessage<'a>{data:&'a u32,}// The second for<> is written out for clarity, but could be elided.structHandler<for<'a>T<'a>>(Option<Box<for<'a> Fn(T<'a>)>>);structCfg{handler:Handler<Message>,}
That's completely reasonable... but sort of complicated to implement. Possibly a duplicate of rust-lang/rfcs#324 .
Ah, I was wondering if this was the same as HKT or not: the frustrating part about this it's that it's already possible if you get rid of Handler and always write the signature in full, so it feels like a failure of the language that you can't refactor out the common code.
This currently does not compile:
This precludes a lot of useful patterns.
The text was updated successfully, but these errors were encountered: