1 2 3 4 5 6 7 8 9 10 11 12 13 14
pub trait Summary { fn summarize(&self) -> String; } pub struct NewsArticle { pub author: String, pub content: String, } impl Summary for NewsArticle { fn summarize(&self) -> String { format!("{}==000===>{}", self.author, self.content) } }