Reputation: 130
I'd like to define a trait like so (to avoid repetition later):
trait Callback: FnOnce() + Send {}
However, the compiler demands that I define Output from FnOnce:
error: the value of the associated type
Output
(from the traitcore::ops::FnOnce
) must be specified [E0191]
I tried to default the value, but it warns that this is unstable.
type Output = ();
error: associated type defaults are unstable
What can I define Output as to indicate "No return"? The normal function call syntax simply omits it.
Upvotes: 3
Views: 695
Reputation: 58975
You can fix this by being explicit about the return type:
trait Callback: FnOnce() -> () + Send {}
I'm honestly not sure if this is a bug or not.
Upvotes: 5