-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Description
Currently to be able to store something in State
, the data needs to implement the StateData
trait. This StateData
trait is really just an alias for Any + Send
. It would be really nice if implementing this trait would not be needed. Here are some reasons why:
- Not technically needed. This abstraction is not actually needed. As you can see in this branch, the
StateData
can be removed and replaced with directAny + Send
without issues. There is thus no technical reason for the existence of this trait. - Unnecessary boilerplate. To be able to store a struct in
gotham::state::State
, you need to either add theStateData
proc-macro to the declaration, or manually implementgotham::state::StateData
. This is an extra line of code that is not needed. - Forces unnecessary wrapper structs. If you want to store a structure from a crate outside of yours in
State
, you need to wrap it with of a wrapper struct just so you can implementStateData
. This adds unnecessary bloat.
I propose that the StateData
trait and StateData
proc-macro are removed. All methods on State
and FromState
that currently take a StateData
would take any Any + Send
instead.
More benefits:
- This would also be one less thing that users need to learn about when starting out with Gotham.
- Removes ~150 LOC from gotham and examples.