https://doc.rust-jp.rs/book-ja/ch10-02-traits.html#%E3%83%88%E3%83%AC%E3%82%A4%E3%83%88%E3%82%92%E5%AE%9F%E8%A3%85%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E5%9E%8B%E3%82%92%E8%BF%94%E3%81%99 [[impl Trait構文]]を使って、特定の[[トレイト]]を実装している型を返却する表現ができる。 ```rust fn return_summarizable() -> impl Summary { Tweet { username: String::from("mimizou"), content: String::from("hogehoge"), reply: false, retweet: false, } } pub struct Tweet { pub username: String, pub content: String, pub reply: bool, pub retweet: bool, } pub trait Summary { fn summarize(&self) -> String { String::from("(Read more...)") } } impl Summary for Tweet { fn summarize(&self) -> String { format!("{}: {}", self.username, self.content) } } ``` > [!caution] > ただし、戻り値の型が1種類に定まらない場合は利用できない。