aboutsummaryrefslogtreecommitdiff
path: root/src/chain.rs
diff options
context:
space:
mode:
authorTill Höppner2016-02-25 06:58:22 +0100
committerTill Höppner2016-02-25 06:58:22 +0100
commitcd15d4f8de1ee9bc6d00fb0a08659ca2c74d2e2d (patch)
tree66b6a4fff228446fc46f4b47ba3b8551ba46e8b2 /src/chain.rs
parent9f5dd9dad6b13476bab2c6eb3c6528f8ad49311a (diff)
downloadilc-cd15d4f8de1ee9bc6d00fb0a08659ca2c74d2e2d.tar.gz
ilc-cd15d4f8de1ee9bc6d00fb0a08659ca2c74d2e2d.tar.xz
ilc-cd15d4f8de1ee9bc6d00fb0a08659ca2c74d2e2d.zip
Update Cargo.toml files with more metadata
Diffstat (limited to 'src/chain.rs')
-rw-r--r--src/chain.rs54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/chain.rs b/src/chain.rs
deleted file mode 100644
index a8014b8..0000000
--- a/src/chain.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-use std::io::{Read, Result, Write};
-
-pub struct Chain<T> {
- elem: Vec<T>,
- index: usize,
-}
-
-impl<T: Read> Read for Chain<T> {
- fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
- 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),
- }
- }
- }
-}
-
-impl<T: Write> Write for Chain<T> {
- fn write(&mut self, buf: &[u8]) -> Result<usize> {
- 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),
- }
- }
- }
-
- fn flush(&mut self) -> Result<()> {
- match self.elem.get_mut(self.index) {
- Some(ref mut r) => r.flush(),
- None => Ok(()),
- }
- }
-}
-
-impl<T> Chain<T> {
- pub fn new(elem: Vec<T>) -> Chain<T> {
- Chain {
- index: 0,
- elem: elem,
- }
- }
-}