Skip to content

Commit

Permalink
Tidy up the style throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Dec 1, 2014
1 parent 7e02580 commit 861f52e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<R: Reader> CrcReader<R> {
CrcReader { inner: r, crc: Crc::new() }
}
pub fn crc(&self) -> &Crc { &self.crc }
pub fn unwrap(self) -> R { self.inner }
pub fn into_inner(self) -> R { self.inner }
pub fn inner(&mut self) -> &mut R { &mut self.inner }
}

Expand Down
2 changes: 1 addition & 1 deletion src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<R: Reader> EncoderReader<R> {
}

/// Consumes this encoder, returning the underlying reader.
pub fn unwrap(self) -> R {
pub fn into_inner(self) -> R {
self.inner.inner
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/gz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::io::{BytesReader,IoResult, IoError};
use std::io;
use std::os;
use std::slice::bytes;
use libc;

use {BestCompression, CompressionLevel, BestSpeed};
use crc::{CrcReader, Crc};
Expand Down Expand Up @@ -252,8 +251,8 @@ impl<R: Reader> EncoderReader<R> {
}

/// Returns the underlying stream, consuming this encoder
pub fn unwrap(self) -> R {
self.inner.inner.unwrap()
pub fn into_inner(self) -> R {
self.inner.inner.into_inner()
}

fn read_footer(&mut self, into: &mut [u8]) -> IoResult<uint> {
Expand Down Expand Up @@ -310,9 +309,8 @@ impl<R: Reader> DecoderReader<R> {
/// If an error is encountered when parsing the gzip header, an error is
/// returned.
pub fn new(r: R) -> IoResult<DecoderReader<R>> {
// from here, all reads should go through this reader (not r):
let mut crc_reader = CrcReader::new( r );

let mut crc_reader = CrcReader::new(r);

let id1 = try!(crc_reader.read_u8());
let id2 = try!(crc_reader.read_u8());
if id1 != 0x1f || id2 != 0x8b { return Err(bad_header()) }
Expand Down Expand Up @@ -356,12 +354,13 @@ impl<R: Reader> DecoderReader<R> {
};

if flg & FHCRC != 0 {
let calced_crc = crc_reader.crc().sum() & 0xFFFF;
let stored_crc = try!(crc_reader.read_le_u16()) as libc::c_ulong;
let calced_crc = crc_reader.crc().sum() as u16;
let stored_crc = try!(crc_reader.read_le_u16());
if calced_crc != stored_crc { return Err(corrupt()) }
}

let flate = raw::DecoderReader::new(crc_reader.unwrap(), true, Vec::with_capacity(128 * 1024));
let flate = raw::DecoderReader::new(crc_reader.into_inner(), true,
Vec::with_capacity(128 * 1024));
return Ok(DecoderReader {
inner: CrcReader::new(flate),
header: Header {
Expand Down
2 changes: 1 addition & 1 deletion src/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<R: Reader> EncoderReader<R> {
}

/// Consumes this encoder, returning the underlying reader.
pub fn unwrap(self) -> R {
pub fn into_inner(self) -> R {
self.inner.inner
}
}
Expand Down

0 comments on commit 861f52e

Please sign in to comment.