diff options
author | Jordan Gong <jordan.gong@protonmail.com> | 2020-09-02 21:00:12 +0800 |
---|---|---|
committer | Jordan Gong <jordan.gong@protonmail.com> | 2020-09-02 21:00:12 +0800 |
commit | 5626a54d626cfe520ba879c42fc9dd0331c76eb9 (patch) | |
tree | 3ede9f0f8c3f2121a30d59e644f641c2a0c1d45e /traits/src/main.rs | |
parent | a8a40420b4106d66bdf1c447388404896dccd494 (diff) |
Share behavior with traits
Diffstat (limited to 'traits/src/main.rs')
-rw-r--r-- | traits/src/main.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/traits/src/main.rs b/traits/src/main.rs new file mode 100644 index 0000000..02e408b --- /dev/null +++ b/traits/src/main.rs @@ -0,0 +1,26 @@ +use traits::{self, NewsArticle, Summary, Tweet, notify}; + +fn main() { + let tweet = Tweet { + username: String::from("horse_ebooks"), + content: String::from("of course, as you probably already know, people"), + reply: false, + retweet: false, + }; + + println!("1 new tweet: {}", tweet.summarize()); + + let article = NewsArticle { + headline: String::from("Penguins win the Stanley Cup Championship!"), + location: String::from("Pittsburgh, PA, USA"), + author: String::from("Iceburgh"), + content: String::from( + "The Pittsburgh Penguins once again are the best \ + hockey team in the NHL.", + ), + }; + + println!("New article available! {}", article.summarize()); + + notify(&article); +} |