https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html
Listing 17-18
struct Published {}
impl State for Published {
// --snip--
fn content<'a>(&self, post: &'a Post) -> &'a str {
&post.content
}
}
- Why is
Publishedan empty struct, vs having acontent-like property (let's saydata) to store the final content? - Follow-up: Why does
content()now have apostparameter? I get it has to do withPublishedbeing empty, and I understand the lifetime additions, but I do not see anywhere in the full code body wherecontentis being called with a parameter. Why would I not reference aPublished.datafrom thecontentmethod?