Skip to content

Commit f674bcb

Browse files
authored
Clean warning and cargo clippy (#41)
* clean warning and cargo clippy * clean warning in example
1 parent 4f5092c commit f674bcb

20 files changed

Lines changed: 213 additions & 144 deletions

.github/workflows/rust.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Push or PR
2+
3+
on:
4+
[push, pull_request]
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
build_n_test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
16+
runs-on: ${{ matrix.os }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: rustfmt
21+
if: ${{ !cancelled() }}
22+
run: cargo fmt --all -- --check
23+
- name: check
24+
if: ${{ !cancelled() }}
25+
run: cargo check --verbose
26+
- name: clippy
27+
if: ${{ !cancelled() }}
28+
run: |
29+
cargo clippy --all-targets -- -D warnings
30+
cargo clippy --all-targets -- -D warnings
31+
cargo clippy --all-targets -- -D warnings
32+
- name: Build
33+
if: ${{ !cancelled() }}
34+
run: |
35+
cargo build --verbose --examples --tests
36+
cargo build --verbose --examples --tests
37+
cargo build --verbose --examples --tests
38+
- name: Abort on error
39+
if: ${{ failure() }}
40+
run: echo "Some of jobs failed" && false
41+
42+
43+
semver:
44+
name: Check semver
45+
strategy:
46+
matrix:
47+
os: [ubuntu-latest, macos-latest, windows-latest]
48+
runs-on: ${{ matrix.os }}
49+
steps:
50+
- uses: actions/checkout@v4
51+
- uses: actions-rs/toolchain@v1
52+
with:
53+
profile: minimal
54+
toolchain: stable
55+
override: true
56+
- uses: obi1kenobi/cargo-semver-checks-action@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Cargo.lock
33
**/*.rs.bk
44
.vscode
55
src/xml
6+
.idea

examples/auth.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl GuardedFileSystem<Filter> for FilteredFs {
8888
path: &'a DavPath,
8989
options: OpenOptions,
9090
_credentials: &'a Filter,
91-
) -> FsFuture<Box<dyn DavFile>> {
91+
) -> FsFuture<'a, Box<dyn DavFile>> {
9292
self.inner.open(path, options, &())
9393
}
9494

@@ -97,7 +97,7 @@ impl GuardedFileSystem<Filter> for FilteredFs {
9797
path: &'a DavPath,
9898
meta: ReadDirMeta,
9999
filter: &'a Filter,
100-
) -> FsFuture<FsStream<Box<dyn DavDirEntry>>> {
100+
) -> FsFuture<'a, FsStream<Box<dyn DavDirEntry>>> {
101101
Box::pin(async move {
102102
let mut stream = self.inner.read_dir(path, meta, &()).await?;
103103
let mut entries = Vec::default();
@@ -115,7 +115,7 @@ impl GuardedFileSystem<Filter> for FilteredFs {
115115
&'a self,
116116
path: &'a DavPath,
117117
_credentials: &'a Filter,
118-
) -> FsFuture<Box<dyn DavMetaData>> {
118+
) -> FsFuture<'a, Box<dyn DavMetaData>> {
119119
self.inner.metadata(path, &())
120120
}
121121
}

src/async_stream.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ impl<I, E> Sender<I, E> {
112112
#[must_use]
113113
pub struct AsyncStream<Item, Error> {
114114
item: Sender<Item, Error>,
115+
#[allow(clippy::type_complexity)]
115116
fut: Option<Pin<Box<dyn Future<Output = Result<(), Error>> + 'static + Send>>>,
116117
}
117118

src/conditional.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ pub(crate) fn etaglist_match(
5252
}
5353

5454
// Handle the if-headers: RFC 7232, HTTP/1.1 Conditional Requests.
55-
pub(crate) fn http_if_match(
56-
req: &Request,
57-
meta: Option<&Box<dyn DavMetaData>>,
58-
) -> Option<StatusCode> {
55+
pub(crate) fn http_if_match(req: &Request, meta: Option<&dyn DavMetaData>) -> Option<StatusCode> {
5956
let file_modified = meta.and_then(|m| m.modified().ok());
6057

6158
if let Some(r) = req.headers().typed_get::<davheaders::IfMatch>() {
@@ -177,7 +174,7 @@ where
177174
match fs.metadata(p, credentials).await {
178175
Ok(meta) => {
179176
// exists and may have metadata ..
180-
if let Some(mtag) = ETag::from_meta(meta) {
177+
if let Some(mtag) = ETag::from_meta(meta.as_ref()) {
181178
tag == &mtag
182179
} else {
183180
false
@@ -210,7 +207,7 @@ where
210207
// Handle both the HTTP conditional If: headers, and the webdav If: header.
211208
pub(crate) async fn if_match<'a, C>(
212209
req: &'a Request,
213-
meta: Option<&'a Box<dyn DavMetaData + 'static>>,
210+
meta: Option<&'a (dyn DavMetaData + 'static)>,
214211
fs: &'a (dyn GuardedFileSystem<C> + 'static),
215212
ls: &'a Option<Box<dyn DavLockSystem + 'static>>,
216213
path: &'a DavPath,
@@ -229,7 +226,7 @@ where
229226
// Like if_match, but also returns all "associated state-tokens"
230227
pub(crate) async fn if_match_get_tokens<'a, C>(
231228
req: &'a Request,
232-
meta: Option<&'a Box<dyn DavMetaData + 'static>>,
229+
meta: Option<&'a (dyn DavMetaData + 'static)>,
233230
fs: &'a (dyn GuardedFileSystem<C> + 'static),
234231
ls: &'a Option<Box<dyn DavLockSystem + 'static>>,
235232
path: &'a DavPath,

src/davheaders.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ impl Header for ContentLanguage {
156156
where
157157
I: Iterator<Item = &'i HeaderValue>,
158158
{
159-
let h = match headers::Vary::decode(values) {
160-
Err(e) => return Err(e),
161-
Ok(h) => h,
162-
};
159+
let h = headers::Vary::decode(values)?;
163160
for lang in h.iter_strs() {
164161
let lang = lang.as_bytes();
165162
// **VERY** rudimentary check ...
@@ -199,7 +196,7 @@ impl Header for Timeout {
199196
{
200197
let value = one(values)?;
201198
let mut v = Vec::new();
202-
let words = value.to_str().map_err(map_invalid)?.split(|c| c == ',');
199+
let words = value.to_str().map_err(map_invalid)?.split(',');
203200
for word in words {
204201
let w = match word {
205202
"Infinite" => DavTimeout::Infinite,
@@ -322,8 +319,8 @@ impl ETag {
322319
}
323320
}
324321

325-
pub fn from_meta(meta: impl AsRef<dyn DavMetaData>) -> Option<ETag> {
326-
let tag = meta.as_ref().etag()?;
322+
pub fn from_meta(meta: &dyn DavMetaData) -> Option<ETag> {
323+
let tag = meta.etag()?;
327324
Some(ETag {
328325
tag: format!("\"{}\"", tag),
329326
weak: false,

0 commit comments

Comments
 (0)