transport 0.1.0

Transport abstraction library with nat traversal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fmt;

pub struct DisplaySlice<'a, T: 'a>(pub &'static str, pub &'a [T]);

impl<'a, T> fmt::Display for DisplaySlice<'a, T>
        where T: fmt::Display
{
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let DisplaySlice(description, slice) = *self;
        let len = slice.len();
        try!(write!(f, "{} {}(s):", len, description));
        for (i, t) in slice.iter().enumerate() {
            try!(write!(f, " ({} of {}) {}", i + 1, len, t));
        }
        Ok(())
    }
}