#[derive(serde::Serialize)]
struct IndexLink<'r>{
text: &'r str,
link: &'r str;
}
#[derive(serde::Serialize)]
struct IndexContext<'r> {
title: &'r str,
links: Vec<&'r IndexLink<&'r>>
}
#[get("/")]
pub fn index() -> Template {
Template::render("index", &IndexContext{
title : "My home on the web",
links: vec![IndexLink{text: "About", link: "/about"}, IndexLink{text: "RSS Feed", link: "/feed"}]
})
}
causes error[E0277]: the trait bound IndexContext<'_>: Serialize is not satisfied
. The error occurs from the line adding the vec
of IndexLink
's to the IndexContent
when rendering the template. I must be doing something wrong with the lifetimes.
Why is this error happening?
Vec<&'r IndexLink<&'r>>
toVec<&'r IndexLink<'r>>
? Thanks though, if you post as an answer I will accept it :) – 636f6e6f7262726f73