30
30
#![ feature( unique) ]
31
31
#![ cfg_attr( test, feature( rustc_private, rand, vec_push_all) ) ]
32
32
33
- #[ cfg( test) ] #[ macro_use] extern crate log;
33
+ #[ cfg( test) ]
34
+ #[ macro_use]
35
+ extern crate log;
34
36
35
37
extern crate libc;
36
38
@@ -47,9 +49,7 @@ pub struct Error {
47
49
48
50
impl Error {
49
51
fn new ( ) -> Error {
50
- Error {
51
- _unused : ( ) ,
52
- }
52
+ Error { _unused : ( ) }
53
53
}
54
54
}
55
55
@@ -73,7 +73,9 @@ impl Deref for Bytes {
73
73
74
74
impl Drop for Bytes {
75
75
fn drop ( & mut self ) {
76
- unsafe { libc:: free ( * self . ptr as * mut _ ) ; }
76
+ unsafe {
77
+ libc:: free ( * self . ptr as * mut _ ) ;
78
+ }
77
79
}
78
80
}
79
81
@@ -123,7 +125,7 @@ pub fn deflate_bytes_zlib(bytes: &[u8]) -> Bytes {
123
125
deflate_bytes_internal ( bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER )
124
126
}
125
127
126
- fn inflate_bytes_internal ( bytes : & [ u8 ] , flags : c_int ) -> Result < Bytes , Error > {
128
+ fn inflate_bytes_internal ( bytes : & [ u8 ] , flags : c_int ) -> Result < Bytes , Error > {
127
129
unsafe {
128
130
let mut outsz: size_t = 0 ;
129
131
let res = tinfl_decompress_mem_to_heap ( bytes. as_ptr ( ) as * const _ ,
@@ -142,12 +144,12 @@ fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Result<Bytes,Error> {
142
144
}
143
145
144
146
/// Decompress a buffer, without parsing any sort of header on the input.
145
- pub fn inflate_bytes ( bytes : & [ u8 ] ) -> Result < Bytes , Error > {
147
+ pub fn inflate_bytes ( bytes : & [ u8 ] ) -> Result < Bytes , Error > {
146
148
inflate_bytes_internal ( bytes, 0 )
147
149
}
148
150
149
151
/// Decompress a buffer that starts with a zlib header.
150
- pub fn inflate_bytes_zlib ( bytes : & [ u8 ] ) -> Result < Bytes , Error > {
152
+ pub fn inflate_bytes_zlib ( bytes : & [ u8 ] ) -> Result < Bytes , Error > {
151
153
inflate_bytes_internal ( bytes, TINFL_FLAG_PARSE_ZLIB_HEADER )
152
154
}
153
155
@@ -176,7 +178,8 @@ mod tests {
176
178
let cmp = deflate_bytes ( & input) ;
177
179
let out = inflate_bytes ( & cmp) . unwrap ( ) ;
178
180
debug ! ( "{} bytes deflated to {} ({:.1}% size)" ,
179
- input. len( ) , cmp. len( ) ,
181
+ input. len( ) ,
182
+ cmp. len( ) ,
180
183
100.0 * ( ( cmp. len( ) as f64 ) / ( input. len( ) as f64 ) ) ) ;
181
184
assert_eq ! ( & * input, & * out) ;
182
185
}
0 commit comments