Closed oblique closed 2 years ago
I don't think this should be explicitly requested, but rather implicitly provided.
What I mean by that, is that states and events should follow https://rust-lang.github.io/api-guidelines/interoperability.html#types-eagerly-implement-common-traits-c-common-traits and these types should be implemented by default wherever possible.
That would be great, however I think it will hard and close to impossible to implement it.
The impossible part is when States
or Events
take as data a non-std type, which we do not know that traits it implements.
We could reformulate the enums to accomodate this:
enum _InternalState<S1, S2> {
State1(S1),
State2(S2),
}
impl<S1, S2> Debug for _InternalState<S1, S2>
where
S1: Debug,
S2: Debug
{
// .. blah
}
type State = _InternalState<KNOWN_S1_DATA, KNOWN_S2_DATA>;
This would require manual implementation of the traits, but would make ti possible to conditionally bound the impls on the concrete types
Correct. Didn't think about it :)
Some users may want to use derive on
States
andEvents
.A possible syntax can be:
Any comments or other ideas?