-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Support rocket 0.5.0-rc.1 based on @flo-l's PR #495
Conversation
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.
Thank you for working on this!
If you add a separate commit that bumps the askama_rocket version to an rc as well, I'd be happy to push that out to crates.io if that helps anyone.
askama_rocket/src/lib.rs
Outdated
@@ -6,11 +6,11 @@ pub use rocket::request::Request; | |||
use rocket::response::Response; | |||
pub use rocket::response::{Responder, Result}; | |||
|
|||
pub fn respond<T: Template>(t: &T, ext: &str) -> Result<'static> { | |||
pub fn respond<'r, 'o, 'r, T: Template>(t: &'r T, ext: &'r str) -> Result<'o> { |
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.
Uh, is it actually useful/necessary to have two lifetimes with the same name? That seems potentially confusing.
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.
Ah! It was from upstream. I have removed the subsequent lifetime.
I have bumped the version to 0.11.0-rc.1 and addressed the comment above. Rocket 0.5 should be out by the end of the week. I will submit another PR pointing to the release version once that happens. |
askama_rocket/src/lib.rs
Outdated
@@ -6,11 +6,11 @@ pub use rocket::request::Request; | |||
use rocket::response::Response; | |||
pub use rocket::response::{Responder, Result}; | |||
|
|||
pub fn respond<T: Template>(t: &T, ext: &str) -> Result<'static> { | |||
pub fn respond<'r, 'o, T: Template>(t: &'r T, ext: &'r str) -> Result<'o> { |
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.
Sorry, I'm still confused: why do we need 'o
here? Since there is no input parameter that uses 'o
, couldn't we keep it as is, with the return type using 'static
directly?
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.
We don't. Thank you for pointing that out. The lifetimes are part of Rocket's Responder signature. In our case we should be able to get away with elided param lifetimes and a static out lifetime.
askama_shared/src/generator.rs
Outdated
self.write_header( | ||
buf, | ||
"::askama_rocket::Responder<'askama>", | ||
Some(vec![param]), | ||
"::askama_rocket::Responder<'askama, 'out>", |
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.
It seems like here, too, we can simplify to just using 'static
for the output lifetime?
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.
Yep. Fixed. Thank you.
thanks @shritesh 🙂 I was just looking to try askama and rocket 5 |
I just tried this, and am getting errors about the generated Relevant dependencies: askama = { version = "0.10.5", features = ["with-rocket"] }
askama_rocket = "0.11.0-rc.1"
rocket = "0.5.0-rc.1" First template derive that fails: #[derive(Template)]
#[template(path = "index.html")]
struct IndexTemplate; Error message:
Full code: https://github.com/jplatte/turbo.fish/compare/askama |
Doesn't look like you're doing anything wrong. Want to file a new issue (or even better, a PR)? |
Builds off #412
Originally posted by @shritesh in #412 (comment)
Originally posted by @djc in #412 (comment)