We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f120e8d commit 5e02b9fCopy full SHA for 5e02b9f
rustlang_book/traits/src/main.rs
@@ -25,6 +25,11 @@ impl Summary for Tweet {
25
return format!("{}: {}", self.username, self.content);
26
}
27
28
+
29
+pub fn notify(item: &impl Summary) {
30
+ println!("Breaking news!! {}", item.summarize());
31
+}
32
33
fn main() {
34
let tweet = Tweet {
35
username: String::from("just_a_kid_with_a_dream"),
@@ -33,7 +38,7 @@ fn main() {
38
retweet: false,
39
};
40
36
- println!("1 new tweet: {}", tweet.summarize());
41
+ notify(&tweet);
37
42
43
let article = NewsArticle {
44
headline: String::from("Penguins win the Stanley Cup Championship!"),
@@ -45,5 +50,5 @@ fn main() {
45
50
),
46
51
47
52
48
- println!("New article available! {}", article.summarize());
53
+ notify(&article);
49
54
0 commit comments