Skip to content

Commit f86396e

Browse files
committed
style: use rustfmt
1 parent b1486da commit f86396e

File tree

5 files changed

+1286
-486
lines changed

5 files changed

+1286
-486
lines changed

benches/bench.rs

Lines changed: 116 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ extern crate rand;
55
extern crate test;
66

77
macro_rules! bench_num {
8-
($name:ident, $read:ident, $bytes:expr, $data:expr) => (
8+
($name:ident, $read:ident, $bytes:expr, $data:expr) => {
99
mod $name {
10-
use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian};
11-
use super::test::Bencher;
1210
use super::test::black_box as bb;
11+
use super::test::Bencher;
12+
use byteorder::{
13+
BigEndian, ByteOrder, LittleEndian, NativeEndian,
14+
};
1315

1416
const NITER: usize = 100_000;
1517

@@ -43,14 +45,16 @@ macro_rules! bench_num {
4345
});
4446
}
4547
}
46-
);
48+
};
4749
($ty:ident, $max:ident,
48-
$read:ident, $write:ident, $size:expr, $data:expr) => (
50+
$read:ident, $write:ident, $size:expr, $data:expr) => {
4951
mod $ty {
50-
use std::$ty;
51-
use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian};
52-
use super::test::Bencher;
5352
use super::test::black_box as bb;
53+
use super::test::Bencher;
54+
use byteorder::{
55+
BigEndian, ByteOrder, LittleEndian, NativeEndian,
56+
};
57+
use std::$ty;
5458

5559
const NITER: usize = 100_000;
5660

@@ -117,7 +121,7 @@ macro_rules! bench_num {
117121
});
118122
}
119123
}
120-
);
124+
};
121125
}
122126

123127
bench_num!(u16, MAX, read_u16, write_u16, 2, [1, 2]);
@@ -127,8 +131,7 @@ bench_num!(i32, MAX, read_i32, write_i32, 4, [1, 2, 3, 4]);
127131
bench_num!(u64, MAX, read_u64, write_u64, 8, [1, 2, 3, 4, 5, 6, 7, 8]);
128132
bench_num!(i64, MAX, read_i64, write_i64, 8, [1, 2, 3, 4, 5, 6, 7, 8]);
129133
bench_num!(f32, MAX, read_f32, write_f32, 4, [1, 2, 3, 4]);
130-
bench_num!(f64, MAX, read_f64, write_f64, 8,
131-
[1, 2, 3, 4, 5, 6, 7, 8]);
134+
bench_num!(f64, MAX, read_f64, write_f64, 8, [1, 2, 3, 4, 5, 6, 7, 8]);
132135

133136
bench_num!(uint_1, read_uint, 1, [1]);
134137
bench_num!(uint_2, read_uint, 2, [1, 2]);
@@ -149,119 +152,148 @@ bench_num!(int_7, read_int, 7, [1, 2, 3, 4, 5, 6, 7]);
149152
bench_num!(int_8, read_int, 8, [1, 2, 3, 4, 5, 6, 7, 8]);
150153

151154
#[cfg(byteorder_i128)]
152-
bench_num!(u128, MAX, read_u128, write_u128,
153-
16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
154-
#[cfg(byteorder_i128)]
155-
bench_num!(i128, MAX, read_i128, write_i128,
156-
16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
155+
bench_num!(
156+
u128,
157+
MAX,
158+
read_u128,
159+
write_u128,
160+
16,
161+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
162+
);
163+
#[cfg(byteorder_i128)]
164+
bench_num!(
165+
i128,
166+
MAX,
167+
read_i128,
168+
write_i128,
169+
16,
170+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
171+
);
157172

158173
#[cfg(byteorder_i128)]
159-
bench_num!(uint128_1, read_uint128,
160-
1, [1]);
174+
bench_num!(uint128_1, read_uint128, 1, [1]);
161175
#[cfg(byteorder_i128)]
162-
bench_num!(uint128_2, read_uint128,
163-
2, [1, 2]);
176+
bench_num!(uint128_2, read_uint128, 2, [1, 2]);
164177
#[cfg(byteorder_i128)]
165-
bench_num!(uint128_3, read_uint128,
166-
3, [1, 2, 3]);
178+
bench_num!(uint128_3, read_uint128, 3, [1, 2, 3]);
167179
#[cfg(byteorder_i128)]
168-
bench_num!(uint128_4, read_uint128,
169-
4, [1, 2, 3, 4]);
180+
bench_num!(uint128_4, read_uint128, 4, [1, 2, 3, 4]);
170181
#[cfg(byteorder_i128)]
171-
bench_num!(uint128_5, read_uint128,
172-
5, [1, 2, 3, 4, 5]);
182+
bench_num!(uint128_5, read_uint128, 5, [1, 2, 3, 4, 5]);
173183
#[cfg(byteorder_i128)]
174-
bench_num!(uint128_6, read_uint128,
175-
6, [1, 2, 3, 4, 5, 6]);
184+
bench_num!(uint128_6, read_uint128, 6, [1, 2, 3, 4, 5, 6]);
176185
#[cfg(byteorder_i128)]
177-
bench_num!(uint128_7, read_uint128,
178-
7, [1, 2, 3, 4, 5, 6, 7]);
186+
bench_num!(uint128_7, read_uint128, 7, [1, 2, 3, 4, 5, 6, 7]);
179187
#[cfg(byteorder_i128)]
180-
bench_num!(uint128_8, read_uint128,
181-
8, [1, 2, 3, 4, 5, 6, 7, 8]);
188+
bench_num!(uint128_8, read_uint128, 8, [1, 2, 3, 4, 5, 6, 7, 8]);
182189
#[cfg(byteorder_i128)]
183-
bench_num!(uint128_9, read_uint128,
184-
9, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
190+
bench_num!(uint128_9, read_uint128, 9, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
185191
#[cfg(byteorder_i128)]
186-
bench_num!(uint128_10, read_uint128,
187-
10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
192+
bench_num!(uint128_10, read_uint128, 10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
188193
#[cfg(byteorder_i128)]
189-
bench_num!(uint128_11, read_uint128,
190-
11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
194+
bench_num!(uint128_11, read_uint128, 11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
191195
#[cfg(byteorder_i128)]
192-
bench_num!(uint128_12, read_uint128,
193-
12, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
196+
bench_num!(
197+
uint128_12,
198+
read_uint128,
199+
12,
200+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
201+
);
194202
#[cfg(byteorder_i128)]
195-
bench_num!(uint128_13, read_uint128,
196-
13, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
203+
bench_num!(
204+
uint128_13,
205+
read_uint128,
206+
13,
207+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
208+
);
197209
#[cfg(byteorder_i128)]
198-
bench_num!(uint128_14, read_uint128,
199-
14, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]);
210+
bench_num!(
211+
uint128_14,
212+
read_uint128,
213+
14,
214+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
215+
);
200216
#[cfg(byteorder_i128)]
201-
bench_num!(uint128_15, read_uint128,
202-
15, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
217+
bench_num!(
218+
uint128_15,
219+
read_uint128,
220+
15,
221+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
222+
);
203223
#[cfg(byteorder_i128)]
204-
bench_num!(uint128_16, read_uint128,
205-
16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
224+
bench_num!(
225+
uint128_16,
226+
read_uint128,
227+
16,
228+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
229+
);
206230

207231
#[cfg(byteorder_i128)]
208-
bench_num!(int128_1, read_int128,
209-
1, [1]);
232+
bench_num!(int128_1, read_int128, 1, [1]);
210233
#[cfg(byteorder_i128)]
211-
bench_num!(int128_2, read_int128,
212-
2, [1, 2]);
234+
bench_num!(int128_2, read_int128, 2, [1, 2]);
213235
#[cfg(byteorder_i128)]
214-
bench_num!(int128_3, read_int128,
215-
3, [1, 2, 3]);
236+
bench_num!(int128_3, read_int128, 3, [1, 2, 3]);
216237
#[cfg(byteorder_i128)]
217-
bench_num!(int128_4, read_int128,
218-
4, [1, 2, 3, 4]);
238+
bench_num!(int128_4, read_int128, 4, [1, 2, 3, 4]);
219239
#[cfg(byteorder_i128)]
220-
bench_num!(int128_5, read_int128,
221-
5, [1, 2, 3, 4, 5]);
240+
bench_num!(int128_5, read_int128, 5, [1, 2, 3, 4, 5]);
222241
#[cfg(byteorder_i128)]
223-
bench_num!(int128_6, read_int128,
224-
6, [1, 2, 3, 4, 5, 6]);
242+
bench_num!(int128_6, read_int128, 6, [1, 2, 3, 4, 5, 6]);
225243
#[cfg(byteorder_i128)]
226-
bench_num!(int128_7, read_int128,
227-
7, [1, 2, 3, 4, 5, 6, 7]);
244+
bench_num!(int128_7, read_int128, 7, [1, 2, 3, 4, 5, 6, 7]);
228245
#[cfg(byteorder_i128)]
229-
bench_num!(int128_8, read_int128,
230-
8, [1, 2, 3, 4, 5, 6, 7, 8]);
246+
bench_num!(int128_8, read_int128, 8, [1, 2, 3, 4, 5, 6, 7, 8]);
231247
#[cfg(byteorder_i128)]
232-
bench_num!(int128_9, read_int128,
233-
9, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
248+
bench_num!(int128_9, read_int128, 9, [1, 2, 3, 4, 5, 6, 7, 8, 9]);
234249
#[cfg(byteorder_i128)]
235-
bench_num!(int128_10, read_int128,
236-
10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
250+
bench_num!(int128_10, read_int128, 10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
237251
#[cfg(byteorder_i128)]
238-
bench_num!(int128_11, read_int128,
239-
11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
252+
bench_num!(int128_11, read_int128, 11, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
240253
#[cfg(byteorder_i128)]
241-
bench_num!(int128_12, read_int128,
242-
12, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
254+
bench_num!(
255+
int128_12,
256+
read_int128,
257+
12,
258+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
259+
);
243260
#[cfg(byteorder_i128)]
244-
bench_num!(int128_13, read_int128,
245-
13, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
261+
bench_num!(
262+
int128_13,
263+
read_int128,
264+
13,
265+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
266+
);
246267
#[cfg(byteorder_i128)]
247-
bench_num!(int128_14, read_int128,
248-
14, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]);
268+
bench_num!(
269+
int128_14,
270+
read_int128,
271+
14,
272+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
273+
);
249274
#[cfg(byteorder_i128)]
250-
bench_num!(int128_15, read_int128,
251-
15, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
275+
bench_num!(
276+
int128_15,
277+
read_int128,
278+
15,
279+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
280+
);
252281
#[cfg(byteorder_i128)]
253-
bench_num!(int128_16, read_int128,
254-
16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
255-
282+
bench_num!(
283+
int128_16,
284+
read_int128,
285+
16,
286+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
287+
);
256288

257289
macro_rules! bench_slice {
258290
($name:ident, $numty:ty, $read:ident, $write:ident) => {
259291
mod $name {
260292
use std::mem::size_of;
261293

262-
use byteorder::{ByteOrder, BigEndian, LittleEndian};
263-
use rand::{self, Rng};
294+
use byteorder::{BigEndian, ByteOrder, LittleEndian};
264295
use rand::distributions;
296+
use rand::{self, Rng};
265297
use test::Bencher;
266298

267299
#[bench]
@@ -322,7 +354,7 @@ macro_rules! bench_slice {
322354
});
323355
}
324356
}
325-
}
357+
};
326358
}
327359

328360
bench_slice!(slice_u64, u64, read_u64_into, write_u64_into);

build.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ fn main() {
1414
&mut io::stderr(),
1515
"failed to parse `rustc --version`: {}",
1616
err
17-
).unwrap();
17+
)
18+
.unwrap();
1819
return;
1920
}
2021
};
@@ -39,11 +40,8 @@ struct Version {
3940
impl Version {
4041
fn read() -> Result<Version, String> {
4142
let rustc = env::var_os("RUSTC").unwrap_or(OsString::from("rustc"));
42-
let output = Command::new(&rustc)
43-
.arg("--version")
44-
.output()
45-
.unwrap()
46-
.stdout;
43+
let output =
44+
Command::new(&rustc).arg("--version").output().unwrap().stdout;
4745
Version::parse(&String::from_utf8(output).unwrap())
4846
}
4947

rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
max_width = 79
2+
use_small_heuristics = "max"

src/io.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,7 @@ pub trait ReadBytesExt: io::Read {
903903
/// assert_eq!([f32::consts::PI, 1.0], dst);
904904
/// ```
905905
#[inline]
906-
fn read_f32_into<T: ByteOrder>(
907-
&mut self,
908-
dst: &mut [f32],
909-
) -> Result<()> {
906+
fn read_f32_into<T: ByteOrder>(&mut self, dst: &mut [f32]) -> Result<()> {
910907
{
911908
let buf = unsafe { slice_to_u8_mut(dst) };
912909
try!(self.read_exact(buf));
@@ -951,7 +948,7 @@ pub trait ReadBytesExt: io::Read {
951948
/// assert_eq!([f32::consts::PI, 1.0], dst);
952949
/// ```
953950
#[inline]
954-
#[deprecated(since="1.2.0", note="please use `read_f32_into` instead")]
951+
#[deprecated(since = "1.2.0", note = "please use `read_f32_into` instead")]
955952
fn read_f32_into_unchecked<T: ByteOrder>(
956953
&mut self,
957954
dst: &mut [f32],
@@ -991,10 +988,7 @@ pub trait ReadBytesExt: io::Read {
991988
/// assert_eq!([f64::consts::PI, 1.0], dst);
992989
/// ```
993990
#[inline]
994-
fn read_f64_into<T: ByteOrder>(
995-
&mut self,
996-
dst: &mut [f64],
997-
) -> Result<()> {
991+
fn read_f64_into<T: ByteOrder>(&mut self, dst: &mut [f64]) -> Result<()> {
998992
{
999993
let buf = unsafe { slice_to_u8_mut(dst) };
1000994
try!(self.read_exact(buf));
@@ -1045,7 +1039,7 @@ pub trait ReadBytesExt: io::Read {
10451039
/// assert_eq!([f64::consts::PI, 1.0], dst);
10461040
/// ```
10471041
#[inline]
1048-
#[deprecated(since="1.2.0", note="please use `read_f64_into` instead")]
1042+
#[deprecated(since = "1.2.0", note = "please use `read_f64_into` instead")]
10491043
fn read_f64_into_unchecked<T: ByteOrder>(
10501044
&mut self,
10511045
dst: &mut [f64],

0 commit comments

Comments
 (0)