When using Rocket's State
with omitted lifetimes then a request to the route is handled ok:
#[post("/foo")]
pub fn foo_handler(db: State<Db>) {
// ...
}
However, if explicit lifetimes are provided then Rocket errors on requests with Attempted to retrieve unmanaged state!
:
#[post("/foo")]
pub fn foo_handler<'a>(db: State<&'a Db>) {
// ...
}
There's either something the compiler isn't picking up here or Rocket avoids a safety check, as this compiles ok without any error or warnings. Any ideas?