Are there code redundancies that could be cleaned up with default implementations on traits?
https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html
trait State {
// default implementation
fn content<'a>(&self, post: &'a Post) -> &'a str {
""
}
}
struct Published {}
impl State for Published {
fn content<'a>(&self, post: &'a Post) -> &'a str {
&post.content
}
}
Are there code redundancies that could be cleaned up with default implementations on traits?
https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html