Skip to content

Commit 146dc66

Browse files
Fishrock123jbr
authored andcommitted
ci, src: run clippy on nightly, apply fixes
The rc_buffer thing is similar to http-rs/surf#242
1 parent d6c76e0 commit 146dc66

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878

7979
- uses: actions-rs/toolchain@v1
8080
with:
81-
toolchain: stable
81+
toolchain: nightly
8282
override: true
8383

8484
- name: setup

src/route.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, State: Clone + Send + Sync + 'static> Route<'a, State> {
4343
let mut p = self.path.clone();
4444

4545
if !p.ends_with('/') && !path.starts_with('/') {
46-
p.push_str("/");
46+
p.push('/');
4747
}
4848

4949
if path != "/" {
@@ -289,7 +289,7 @@ where
289289
route_params,
290290
} = req;
291291

292-
let rest = crate::request::rest(&route_params).unwrap_or_else(|| "");
292+
let rest = crate::request::rest(&route_params).unwrap_or("");
293293
req.url_mut().set_path(&rest);
294294

295295
self.0

src/server.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ use crate::{Endpoint, Request, Route};
2828
pub struct Server<State> {
2929
router: Arc<Router<State>>,
3030
state: State,
31+
/// Holds the middleware stack.
32+
///
33+
/// Note(Fishrock123): We do actually want this structure.
34+
/// The outer Arc allows us to clone in .respond() without cloning the array.
35+
/// The Vec allows us to add middleware at runtime.
36+
/// The inner Arc-s allow MiddlewareEndpoint-s to be cloned internally.
37+
/// We don't use a Mutex around the Vec here because adding a middleware during execution should be an error.
38+
#[allow(clippy::rc_buffer)]
3139
middleware: Arc<Vec<Arc<dyn Middleware<State>>>>,
3240
}
3341

0 commit comments

Comments
 (0)