The enum Response { Used, Unused } is a left-over from before #309, where event handlers returned a message directly. Now the type is used only to determine whether an event was used/consumed. The name doesn't fit current usage and overall the type feels clunky.
Actual usage is:
To report whether Widget::handle_event consumes the event, and thus whether to call handle_unused on ancestors
To report whether steal_event intercepts the event
Suggestions:
Remove, instead returning bool. Problem: less clear exactly what true/false means. Problem: potential for returning result of a function call incorrectly.
Re-export Used, Unused directly, including in the prelude. More namespace pollution. Still need the type name in the method signature.
Rename, e.g. to IsUsed. Probably the best option, but the name is uninspired.
The
enum Response { Used, Unused }
is a left-over from before #309, where event handlers returned a message directly. Now the type is used only to determine whether an event was used/consumed. The name doesn't fit current usage and overall the type feels clunky.Actual usage is:
Widget::handle_event
consumes the event, and thus whether to callhandle_unused
on ancestorssteal_event
intercepts the eventSuggestions:
bool
. Problem: less clear exactly whattrue
/false
means. Problem: potential for returning result of a function call incorrectly.Used
,Unused
directly, including in the prelude. More namespace pollution. Still need the type name in the method signature.IsUsed
. Probably the best option, but the name is uninspired.pub struct IsUsed(pub bool)