Through 1.2.2.1

This commit is contained in:
Dan Buch
2016-08-31 11:18:25 -04:00
parent de02f07049
commit 963fe0a864
3 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
use std::fmt;
struct List(Vec<i32>);
impl fmt::Display for List {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let List(ref vec) = *self;
try!(write!(f, "["));
for (count, v) in vec.iter().enumerate() {
if count != 0 { try!(write!(f, ", ")); }
try!(write!(f, "{}", v));
}
write!(f, "]")
}
}
fn main() {
let v = List(vec![1, 2, 3]);
println!("{}", v);
}