Closed bvssvni closed 10 years ago
Struct variants has the benefit of:
Input(input::MouseMove { draw_x, draw_y, .. }) =>
instead of Input(input::MouseMove(input::MouseMoveArgs { draw_x, draw_y, .. })) =>
That said, it isn't bad to have Input(input::MouseMove(args)) =>
. For the pattern we need, this actually makes the code look a bit nicer when you are mapping directly to an application specific method. However, this is a pattern that might have drawbacks. Other methods should use function arguments so you can use them easily through other means.
Here is an example with tuple variants:
Here is the same example with struct variants: https://github.com/PistonDevelopers/piston-examples/blob/15c8a4f91724d312521b39fa81713b8f90706fbe/user_input/src/main.rs#L89
Notice that it looks nicer with tuple variants, but in a real world example you often want to map the whole InputEvent
directly Input(e) => controller.event(&e)
. In such cases it won't make a difference.
I read in the minute logs that struct variants will possibly be removed. https://github.com/rust-lang/meeting-minutes/blob/master/workweek-2014-08-18/versioning.md
Should we go back to Args?
Should we try arguing for keeping struct variants in the language?