Skip to content

Commit 15b8aa0

Browse files
committed
fix clippy lints
1 parent 551c892 commit 15b8aa0

9 files changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
- name: cargo clippy
5858
uses: giraffate/clippy-action@v1
5959
with:
60+
clippy_flags: --workspace --all-targets --all-features -- -Dclippy::all
6061
reporter: 'github-pr-check'
6162
github_token: ${{ secrets.GITHUB_TOKEN }}
6263
semver:

examples/hyper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async fn main() {
9696
)
9797
.await
9898
{
99-
println!("Error serving connection: {:?}", err);
99+
println!("Error serving connection: {err:?}");
100100
}
101101
});
102102
}

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl MergeError {
117117
impl fmt::Display for MergeError {
118118
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
119119
for error in self.0.iter() {
120-
writeln!(f, "{}", error)?;
120+
writeln!(f, "{error}")?;
121121
}
122122

123123
Ok(())

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ by the number of children with registered values, increasing the chance of choos
123123
As it turns out, this method of routing is extremely fast. See the [benchmark results](https://github.com/ibraheemdev/matchit?tab=readme-ov-file#benchmarks) for details.
124124
*/
125125

126-
#![deny(rust_2018_idioms, clippy::all)]
126+
#![deny(
127+
missing_debug_implementations,
128+
missing_docs,
129+
dead_code,
130+
unsafe_op_in_unsafe_fn,
131+
rustdoc::broken_intra_doc_links
132+
)]
127133

128134
mod error;
129135
mod escape;

src/params.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ impl<'k, 'v> Param<'k, 'v> {
2727
}
2828
}
2929

30+
impl<'k, 'v> fmt::Debug for Param<'k, 'v> {
31+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32+
f.debug_struct("Param")
33+
.field("key", &self.key_str())
34+
.field("value", &self.value_str())
35+
.finish()
36+
}
37+
}
38+
3039
/// A list of parameters returned by a route match.
3140
///
3241
/// ```rust
@@ -174,6 +183,7 @@ impl fmt::Debug for Params<'_, '_> {
174183
}
175184

176185
/// An iterator over the keys and values of a route's [parameters](crate::Params).
186+
#[derive(Debug)]
177187
pub struct ParamsIter<'ps, 'k, 'v> {
178188
kind: ParamsIterKind<'ps, 'k, 'v>,
179189
}
@@ -188,6 +198,7 @@ impl<'ps, 'k, 'v> ParamsIter<'ps, 'k, 'v> {
188198
}
189199
}
190200

201+
#[derive(Debug)]
191202
enum ParamsIterKind<'ps, 'k, 'v> {
192203
Small(iter::Take<slice::Iter<'ps, Param<'k, 'v>>>),
193204
Large(slice::Iter<'ps, Param<'k, 'v>>),

src/router.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ impl<T> Router<T> {
132132
self.root.remove(path.into())
133133
}
134134

135+
/// Test helper that ensures route priorities are consistent.
135136
#[cfg(feature = "__test_helpers")]
136137
pub fn check_priorities(&self) -> Result<u32, (u32, u32)> {
137138
self.root.check_priorities()

tests/match.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ fn overlapping_param_backtracking() {
6363

6464
struct MatchTest {
6565
routes: Vec<&'static str>,
66+
#[allow(clippy::type_complexity)]
6667
matches: Vec<(
6768
&'static str,
6869
&'static str,
@@ -88,8 +89,8 @@ impl MatchTest {
8889
let got = x.params.iter().collect::<Vec<_>>();
8990
assert_eq!(params.unwrap(), got);
9091

91-
router.at_mut(path).unwrap().value.push_str("Z");
92-
assert!(router.at(path).unwrap().value.contains("Z"));
92+
router.at_mut(path).unwrap().value.push('Z');
93+
assert!(router.at(path).unwrap().value.contains('Z'));
9394
router.at_mut(path).unwrap().value.pop();
9495
}
9596
Err(err) => {

tests/merge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn merge_conflict() {
3232
let errors = root.merge(child).unwrap_err();
3333

3434
assert_eq!(
35-
errors.get(0),
35+
errors.first(),
3636
Some(&InsertError::Conflict {
3737
with: "/foo".into()
3838
})

tests/remove.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl RemoveTest {
3333
}
3434

3535
for route in self.remaining {
36-
assert!(matches!(router.at(route), Ok(_)), "remaining {route}");
36+
assert!(router.at(route).is_ok(), "remaining {route}");
3737
}
3838
}
3939
}

0 commit comments

Comments
 (0)