Browse Source

trait params function

pull/5/head
jingxun 3 years ago
parent
commit
cba2efa4f9
  1. 4
      day08/trait_day08/src/lib.rs
  2. 3
      day08/trait_day08/src/main.rs

4
day08/trait_day08/src/lib.rs

@ -52,3 +52,7 @@ pub trait Summary {
format!("(Read more from {}...)", self.summarize_authort())
}
}
pub fn notify(item:impl Summary){
println!("Breaking news! {}", item.summarize());
}

3
day08/trait_day08/src/main.rs

@ -9,7 +9,7 @@
** @description: Input here.
*/
use trait_day08::{Tweet, Summary, NewsArticle};
use trait_day08::{Tweet, Summary, NewsArticle, notify};
fn main() {
let tweet = Tweet {
@ -26,4 +26,5 @@ fn main() {
content: String::from("The Pittsubrgh Penguins once again are the best hockey team in the NHL."),
};
println!("New article available! {}", article.summarize());
notify(article);
}

Loading…
Cancel
Save