TRAITS: Move summary trait to separate file

This commit is contained in:
laurens 2020-09-06 16:04:44 +02:00
parent 97e104176e
commit c99a415d16
2 changed files with 9 additions and 7 deletions

View file

@ -1,10 +1,5 @@
pub trait Summary {
fn summarize_author(&self) -> String;
fn summarize(&self) -> String {
format!("(Read more from {}...)", self.summarize_author())
}
}
mod summary;
use summary::Summary;
pub struct NewsArticle {
pub headline: String,

7
traits/src/summary.rs Normal file
View file

@ -0,0 +1,7 @@
pub trait Summary {
fn summarize_author(&self) -> String;
fn summarize(&self) -> String {
format!("(Read more from {}...)", self.summarize_author())
}
}