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
#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.
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)]enumEither<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.
The text was updated successfully, but these errors were encountered:
#31 mostly implemented #6 (support enums), but with a significant missing feature: lack of support for
using
andignore
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 supportDebug
. This was not important for my debugging purposes, but prevented use ofderive
orautoimpl
.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 sinceAddWindow
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 sinceAddWindow
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: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.
The text was updated successfully, but these errors were encountered: