pub trait Summary{
fn summarize(&self) -> String{
format!("Read more from {}...", self.summairze_author())
}
fn summairze_author(&self) -> String;
}
pub struct NewsArticle{
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for NewsArticle{
fn summairze_author(&self) -> String {
format!("@{}", self.author)
}
}
pub struct Tweet{
pub username: String,
pub content: String,
pub reply: bool,
pub retweet: bool,
}
impl Summary for Tweet{
fn summarize(&self) -> String {
format!("{}: {}", self.username, self.content)
}
fn summairze_author(&self) -> String {
format!("@{}", self.username)
}
}