Skip to content

Commit 583ec9e

Browse files
authored
Add cargo fmt --check to CI (#130)
* Add cargo fmt --check to CI Grabbed the incantation from https://github.com/hyperium/hyper/blob/master/.github/workflows/CI.yml Was noticing that my editor was automatically doing this - and figured it's good form to use an autoformatter with default settings. * Add components: rustfmt
1 parent da9485e commit 583ec9e

File tree

8 files changed

+39
-34
lines changed

8 files changed

+39
-34
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
toolchain: ${{ matrix.rust }}
2222
profile: minimal
2323
override: true
24+
components: rustfmt
2425

2526
- name: cargo test --all
2627
uses: actions-rs/cargo@v1
@@ -41,6 +42,12 @@ jobs:
4142
cargo update -Z minimal-versions
4243
cargo check
4344
45+
- name: cargo fmt --check
46+
uses: actions-rs/cargo@v1
47+
with:
48+
command: fmt
49+
args: --all -- --check
50+
4451
MSRV:
4552
runs-on: ubuntu-latest
4653

src/common/content_range.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,23 @@ fn split_in_two(s: &str, separator: char) -> Option<(&str, &str)> {
178178
}
179179

180180
/*
181-
test_header!(test_bytes,
182-
vec![b"bytes 0-499/500"],
183-
Some(ContentRange(ContentRangeSpec::Bytes {
184-
range: Some((0, 499)),
185-
complete_length: Some(500)
186-
})));
187-
188-
test_header!(test_bytes_unknown_len,
189-
vec![b"bytes 0-499/*"],
190-
Some(ContentRange(ContentRangeSpec::Bytes {
191-
range: Some((0, 499)),
192-
complete_length: None
193-
})));
194-
195-
test_header!(test_bytes_unknown_range,
196-
vec![b"bytes */500"],
181+
test_header!(test_bytes,
182+
vec![b"bytes 0-499/500"],
183+
Some(ContentRange(ContentRangeSpec::Bytes {
184+
range: Some((0, 499)),
185+
complete_length: Some(500)
186+
})));
187+
188+
test_header!(test_bytes_unknown_len,
189+
vec![b"bytes 0-499/*"],
190+
Some(ContentRange(ContentRangeSpec::Bytes {
191+
range: Some((0, 499)),
192+
complete_length: None
193+
})));
194+
195+
test_header!(test_bytes_unknown_range,
196+
vec![b"bytes */
197+
500"],
197198
Some(ContentRange(ContentRangeSpec::Bytes {
198199
range: None,
199200
complete_length: Some(500)

src/common/etag.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ error_type!(InvalidETag);
5050
impl FromStr for ETag {
5151
type Err = InvalidETag;
5252
fn from_str(src: &str) -> Result<Self, Self::Err> {
53-
let val = src
54-
.parse()
55-
.map_err(|_| InvalidETag { _inner: () })?;
53+
let val = src.parse().map_err(|_| InvalidETag { _inner: () })?;
5654

5755
EntityTag::from_owned(val)
5856
.map(ETag)

src/common/host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::fmt;
21
use std::convert::TryFrom;
2+
use std::fmt;
33

44
use http::uri::Authority;
55

src/common/if_range.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ impl IfRange {
6464
pub fn is_modified(&self, etag: Option<&ETag>, last_modified: Option<&LastModified>) -> bool {
6565
match self.0 {
6666
IfRange_::Date(since) => last_modified.map(|time| since < time.0).unwrap_or(true),
67-
IfRange_::EntityTag(ref entity) => etag.map(|etag| !etag.0.strong_eq(entity)).unwrap_or(true),
67+
IfRange_::EntityTag(ref entity) => {
68+
etag.map(|etag| !etag.0.strong_eq(entity)).unwrap_or(true)
69+
}
6870
}
6971
}
7072
}

src/common/origin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::fmt;
21
use std::convert::TryFrom;
2+
use std::fmt;
33

44
use bytes::Bytes;
55
use http::uri::{self, Authority, Scheme, Uri};

src/util/entity.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@ impl EntityTag {
167167
}
168168

169169
pub(crate) fn from_val(val: &HeaderValue) -> Option<EntityTag> {
170-
EntityTag::parse(val.as_bytes()).map(|_entity| {
171-
EntityTag(val.clone())
172-
})
170+
EntityTag::parse(val.as_bytes()).map(|_entity| EntityTag(val.clone()))
173171
}
174172
}
175173

@@ -239,11 +237,10 @@ impl EntityTagRange {
239237
{
240238
match *self {
241239
EntityTagRange::Any => true,
242-
EntityTagRange::Tags(ref tags) => {
243-
tags.iter()
244-
.flat_map(EntityTag::<&str>::parse)
245-
.any(|tag| func(&tag, entity))
246-
},
240+
EntityTagRange::Tags(ref tags) => tags
241+
.iter()
242+
.flat_map(EntityTag::<&str>::parse)
243+
.any(|tag| func(&tag, entity)),
247244
}
248245
}
249246
}

src/util/flat_csv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ impl<'a, Sep: Separator> FromIterator<&'a HeaderValue> for FlatCsv<Sep> {
120120
buf.extend_from_slice(val.as_bytes());
121121
}
122122

123-
let val =
124-
HeaderValue::from_maybe_shared(buf.freeze()).expect("comma separated HeaderValues are valid");
123+
let val = HeaderValue::from_maybe_shared(buf.freeze())
124+
.expect("comma separated HeaderValues are valid");
125125

126126
val.into()
127127
}
@@ -151,8 +151,8 @@ impl<Sep: Separator> FromIterator<HeaderValue> for FlatCsv<Sep> {
151151
buf.extend_from_slice(val.as_bytes());
152152
}
153153

154-
let val =
155-
HeaderValue::from_maybe_shared(buf.freeze()).expect("comma separated HeaderValues are valid");
154+
let val = HeaderValue::from_maybe_shared(buf.freeze())
155+
.expect("comma separated HeaderValues are valid");
156156

157157
val.into()
158158
}

0 commit comments

Comments
 (0)