summaryrefslogtreecommitdiff
path: root/rust/theBook/chapter-10-generic-types-traits-lifetimes/traits/src/main.rs
blob: f0229a0228bd4117953e1722aadd78ee2491fadd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use traits::{Tweet, Summary, NewsArticle};

fn main() {
    let tweet = Tweet {
        username: String::from("horse_ebook"),
        content: String::from(
            "of course, as you probably already know, people."
        ),
        reply: false,
        retweet: false,
    };

    println!("1 new tweet: {}", tweet.summarize());

    let article = NewsArticle {
        author: String::from("garhve"),
        headline: String::from("how to die"),
        location: String:: from("United Kingdom"),
        content: String::from("This is how we gonna die"),
    };

    println!("1 new article: {}",article.summarize());
}