mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
304 B
15 lines
304 B
3 years ago
|
use std::fmt;
|
||
|
|
||
|
struct Wrapper(Vec<String>);
|
||
|
|
||
|
impl fmt::Display for Wrapper {
|
||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||
|
write!(f, "[{}]", self.0.join(", "))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let w = Wrapper(vec![String::from("hello"), String::from("world")]);
|
||
|
println!("w = {}", w);
|
||
|
}
|