Skip to content

Commit 94d4895

Browse files
5225225pyfisch
authored andcommitted
Rustfmt/clippy ignore, add benchmarks to clippy/check CI runs
1 parent c6ba5c0 commit 94d4895

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- uses: actions-rs/cargo@v1
1717
with:
1818
command: check
19+
args: --all-targets
1920

2021
test:
2122
name: Test Suite
@@ -61,4 +62,4 @@ jobs:
6162
- uses: actions-rs/cargo@v1
6263
with:
6364
command: clippy
64-
args: -- -D warnings
65+
args: --all-targets -- -D warnings

benches/benchmarks.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use criterion::{black_box, Criterion, criterion_group, criterion_main};
1+
use criterion::{black_box, criterion_group, criterion_main, Criterion};
22

33
pub fn parse_imf_fixdate(c: &mut Criterion) {
44
c.bench_function("parse_imf_fixdate", |b| {
@@ -47,5 +47,11 @@ pub fn encode_date(c: &mut Criterion) {
4747
});
4848
}
4949

50-
criterion_group!(benches, parse_imf_fixdate, parse_rfc850_date, parse_asctime, encode_date);
50+
criterion_group!(
51+
benches,
52+
parse_imf_fixdate,
53+
parse_rfc850_date,
54+
parse_asctime,
55+
encode_date
56+
);
5157
criterion_main!(benches);

src/date.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,13 @@ fn toint_2(s: &[u8]) -> Result<u8, Error> {
260260
}
261261
}
262262

263+
#[allow(clippy::many_single_char_names)]
263264
fn toint_4(s: &[u8]) -> Result<u16, Error> {
264265
let a = u16::from(s[0].wrapping_sub(b'0'));
265266
let b = u16::from(s[1].wrapping_sub(b'0'));
266267
let c = u16::from(s[2].wrapping_sub(b'0'));
267268
let d = u16::from(s[3].wrapping_sub(b'0'));
268-
269+
269270
if a < 10 && b < 10 && c < 10 && d < 10 {
270271
Ok(a * 1000 + b * 100 + c * 10 + d)
271272
} else {
@@ -377,7 +378,13 @@ fn parse_asctime(s: &[u8]) -> Result<HttpDate, Error> {
377378
hour: toint_2(&s[11..13])?,
378379
day: {
379380
let x = &s[8..10];
380-
{if x[0] == b' ' { toint_1(x[1]) } else { toint_2(x) }}?
381+
{
382+
if x[0] == b' ' {
383+
toint_1(x[1])
384+
} else {
385+
toint_2(x)
386+
}
387+
}?
381388
},
382389
mon: match &s[4..8] {
383390
b"Jan " => 1,

0 commit comments

Comments
 (0)