Through 1.2.2.1

This commit is contained in:
Dan Buch 2016-08-31 11:18:25 -04:00
parent de02f07049
commit 963fe0a864
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC
3 changed files with 33 additions and 0 deletions

4
rustbyexample/01221/Cargo.lock generated Normal file
View File

@ -0,0 +1,4 @@
[root]
name = "01221"
version = "0.1.0"

View File

@ -0,0 +1,6 @@
[package]
name = "01221"
version = "0.1.0"
authors = ["Dan Buch <daniel.buch@gmail.com>"]
[dependencies]

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);
}