TRAITS: Move summary trait to separate file
This commit is contained in:
parent
97e104176e
commit
c99a415d16
2 changed files with 9 additions and 7 deletions
|
|
@ -1,10 +1,5 @@
|
||||||
pub trait Summary {
|
mod summary;
|
||||||
fn summarize_author(&self) -> String;
|
use summary::Summary;
|
||||||
|
|
||||||
fn summarize(&self) -> String {
|
|
||||||
format!("(Read more from {}...)", self.summarize_author())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct NewsArticle {
|
pub struct NewsArticle {
|
||||||
pub headline: String,
|
pub headline: String,
|
||||||
|
|
|
||||||
7
traits/src/summary.rs
Normal file
7
traits/src/summary.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
pub trait Summary {
|
||||||
|
fn summarize_author(&self) -> String;
|
||||||
|
|
||||||
|
fn summarize(&self) -> String {
|
||||||
|
format!("(Read more from {}...)", self.summarize_author())
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue