-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve docs regarding state and extensions #2991
Conversation
"state derived from a request" seems like a fairly narrow usecase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"state derived from a request" seems like a fairly narrow usecase. Extension is also useful when converting a previously stateless system into a stateful one, since changing the type of the State parameter also changes the type of the router, which can cause issues.
I agree with how the docs are written now. Extension
has been historically used for passing around application state, but users should use State
for that now. It's type safe and more maintainable.
I'd recommend anyone who needs to make their application stateful to use State
instead of Extension
even though they will have to make more changes if they're passing around Router
s. I can't think of any scenarios other than the one in docs where I'd recommend an Extension
.
well, i genuinely could not get |
@lolbinarycat No, that's not required. Please open a new discussion under Q&A to get help with that. |
Co-authored-by: David Mládek <david.mladek.cz@gmail.com>
Motivation
Issue #2917 mentions that it should be easier to discover the documentation for
Extension
from the docs ofState
and vice versa. Indeed, Extension is very easy to miss as it is only mentioned after a couple of examples.Solution
This PR updates the docs by
Router::with_state
Extension
toextract::State
Closes #2917