Skip to content

Commit

Permalink
ci, src: run clippy on nightly, apply fixes
Browse files Browse the repository at this point in the history
The rc_buffer thing is similar to http-rs/surf#242
  • Loading branch information
Fishrock123 committed Sep 27, 2020
1 parent eaad5b6 commit 97147f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: nightly
override: true

- name: setup
Expand Down
4 changes: 2 additions & 2 deletions src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a, State: Clone + Send + Sync + 'static> Route<'a, State> {
let mut p = self.path.clone();

if !p.ends_with('/') && !path.starts_with('/') {
p.push_str("/");
p.push('/');
}

if path != "/" {
Expand Down Expand Up @@ -286,7 +286,7 @@ where
route_params,
} = req;

let rest = crate::request::rest(&route_params).unwrap_or_else(|| "");
let rest = crate::request::rest(&route_params).unwrap_or("");
req.url_mut().set_path(&rest);

self.0
Expand Down
8 changes: 8 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ use crate::{Endpoint, Request, Route};
pub struct Server<State> {
router: Arc<Router<State>>,
state: State,
/// Holds the middleware stack.
///
/// Note(Fishrock123): We do actually want this structure.
/// The outer Arc allows us to clone in .respond() without cloning the array.
/// The Vec allows us to add middleware at runtime.
/// The inner Arc-s allow MiddlewareEndpoint-s to be cloned internally.
/// We don't use a Mutex around the Vec here because adding a middleware during execution should be an error.
#[allow(clippy::rc_buffer)]
middleware: Arc<Vec<Arc<dyn Middleware<State>>>>,
}

Expand Down

0 comments on commit 97147f0

Please sign in to comment.