diff --git a/web/CHANGES.md b/web/CHANGES.md index 43fc37a9..e2dd29d3 100644 --- a/web/CHANGES.md +++ b/web/CHANGES.md @@ -1,4 +1,6 @@ # unreleased +## Add +- `StateRef` can used for extracting `?Sized` type from application state. # 0.2.1 ## Add diff --git a/web/Cargo.toml b/web/Cargo.toml index d17700d1..81050972 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xitca-web" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "Apache-2.0" description = "an async web framework" diff --git a/web/src/handler/types/state.rs b/web/src/handler/types/state.rs index 27da954f..c87f411a 100644 --- a/web/src/handler/types/state.rs +++ b/web/src/handler/types/state.rs @@ -6,7 +6,9 @@ use crate::{body::BodyStream, context::WebContext, error::Error, handler::FromRe /// App state extractor. /// S type must be the same with the type passed to App::with_xxx_state(S). -pub struct StateRef<'a, S>(pub &'a S); +pub struct StateRef<'a, S>(pub &'a S) +where + S: ?Sized; impl fmt::Debug for StateRef<'_, S> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -32,7 +34,7 @@ impl<'a, 'r, C, B, T> FromRequest<'a, WebContext<'r, C, B>> for StateRef<'a, T> where C: Borrow, B: BodyStream, - T: 'static, + T: ?Sized + 'static, { type Type<'b> = StateRef<'b, T>; type Error = Error;