From e866dceae987acd51d43bd457351bd2188c5f95a Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Tue, 23 Feb 2016 17:00:53 +0100 Subject: Test CI --- src/chain.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/chain.rs') diff --git a/src/chain.rs b/src/chain.rs index 9b9848a..a8014b8 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -1,19 +1,21 @@ -use std::io::{ Result, Read, Write }; +use std::io::{Read, Result, Write}; pub struct Chain { elem: Vec, - index: usize + index: usize, } impl Read for Chain { fn read(&mut self, buf: &mut [u8]) -> Result { loop { match self.elem.get_mut(self.index) { - Some(ref mut r) => match try!(r.read(buf)) { - 0 => self.index += 1, - n => return Ok(n) - }, - None => return Ok(0) + Some(ref mut r) => { + match try!(r.read(buf)) { + 0 => self.index += 1, + n => return Ok(n), + } + } + None => return Ok(0), } } } @@ -23,11 +25,13 @@ impl Write for Chain { fn write(&mut self, buf: &[u8]) -> Result { loop { match self.elem.get_mut(self.index) { - Some(ref mut r) => match try!(r.write(buf)) { - 0 => self.index += 1, - n => return Ok(n) - }, - None => return Ok(0) + Some(ref mut r) => { + match try!(r.write(buf)) { + 0 => self.index += 1, + n => return Ok(n), + } + } + None => return Ok(0), } } } @@ -35,14 +39,16 @@ impl Write for Chain { fn flush(&mut self) -> Result<()> { match self.elem.get_mut(self.index) { Some(ref mut r) => r.flush(), - None => Ok(()) + None => Ok(()), } } - } impl Chain { pub fn new(elem: Vec) -> Chain { - Chain { index: 0, elem: elem } + Chain { + index: 0, + elem: elem, + } } } -- cgit v1.2.3