Updated src/generic_types_traits_and_lifetimes/traits.md'.

This commit is contained in:
Hector PENG
2026-03-22 18:49:25 +08:00
parent 563c824115
commit 0bbf9a9b4d
2 changed files with 35 additions and 32 deletions

View File

@@ -1,5 +1,20 @@
use aggregator::{SocialPost, Summary, NewsArticle};
pub fn notify(item: &impl Summary) {
println! ("突发新闻!{}", item.summarize());
}
fn return_summarizable() -> impl Summary {
SocialPost {
username: String::from("horse_ebooks"),
content: String::from(
"当然,正如咱们或许已经知道的一样,朋友们"
),
reply: false,
retweet: false,
}
}
fn main() {
let post = SocialPost {
username: String::from("horse_ebooks"),