Description
#31 mostly implemented #6 (support enums), but with a significant missing feature: lack of support for using
and ignore
keywords.
The reason is very simple: syntax.
Case study: ignore
I recently wanted to implement Debug
on the following enum. The problem: kas::Window
does not support Debug
. This was not important for my debugging purposes, but prevented use of derive
or autoimpl
.
enum PendingAction<A: crate::AppData> {
AddPopup(WindowId, WindowId, kas::PopupDescriptor),
AddWindow(WindowId, kas::Window<A>),
CloseWindow(WindowId),
Action(kas::Action),
}
This enum's variants use tuple syntax, but ignore self.1
is not specific enough.
This is sufficient: ignore AddWindow::1
. It is not correct Rust syntax since AddWindow
is not a type (though there was a proposal in that direction) and ::1
is not a valid path element (tuples not needing this).
Alternatively: AddWindow.1
. This is also not correct Rust syntax since AddWindow
is not a value, but at least .1
is a valid field accessor, so this may be the better option.
Using multiple fields?
Unlike ignore
, using
normally only targets a single field. Implementing e.g. Deref
on an enum would require a field for each variant. This should not be a problem, however:
#[autoimpl(Deref<Target = T> using A.0, B.0)]
enum Either<T> {
A(T),
B(T),
}
Summary
The above, using .
field accessors, appears a reasonable proposition, despite not being true Rust syntax.
There is motivation for supporting at least ignore
on enums, though given how long it took me to find a real example this appears limited.
I will leave this issue open for now. Comments welcome.