[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix clippy warnings (seanmonstar#894)
Browse files Browse the repository at this point in the history
clippy::from_over_into
clippy::match_like_matches_macro
clippy::needless_borrow
clippy::option_as_ref_deref
clippy::redundant_closure
clippy::single_component_path_imports
clippy::useless_conversion
  • Loading branch information
nickelc committed Sep 10, 2021
1 parent a8dbdb6 commit 79e7bba
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/filter/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ where

let pin = self.project();
let fut = pin.future;
match route::set(&pin.route, || fut.try_poll(cx)) {
match route::set(pin.route, || fut.try_poll(cx)) {
Poll::Ready(Ok(ok)) => Poll::Ready(Ok(ok.into_response())),
Poll::Pending => Poll::Pending,
Poll::Ready(Err(err)) => {
Expand Down
2 changes: 1 addition & 1 deletion src/filters/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn file(path: impl Into<PathBuf>) -> impl FilterClone<Extract = One<File>, E
ArcPath(path.clone())
})
.and(conditionals())
.and_then(|path, conditionals| file_reply(path, conditionals))
.and_then(file_reply)
}

/// Creates a `Filter` that serves a directory at the base `path` joined
Expand Down
4 changes: 2 additions & 2 deletions src/filters/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ impl Part {

/// Get the filename of this part, if present.
pub fn filename(&self) -> Option<&str> {
self.filename.as_ref().map(|s| &**s)
self.filename.as_deref()
}

/// Get the content-type of this part, if present.
pub fn content_type(&self) -> Option<&str> {
self.content_type.as_ref().map(|s| &**s)
self.content_type.as_deref()
}

/// Asynchronously get some of the data for this `Part`.
Expand Down
8 changes: 4 additions & 4 deletions src/filters/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ pub fn param<T: FromStr + Send + 'static>(
/// ```
pub fn tail() -> impl Filter<Extract = One<Tail>, Error = Infallible> + Copy {
filter_fn(move |route| {
let path = path_and_query(&route);
let path = path_and_query(route);
let idx = route.matched_path_index();

// Giving the user the full tail means we assume the full path
Expand Down Expand Up @@ -347,7 +347,7 @@ impl fmt::Debug for Tail {
/// ```
pub fn peek() -> impl Filter<Extract = One<Peek>, Error = Infallible> + Copy {
filter_fn(move |route| {
let path = path_and_query(&route);
let path = path_and_query(route);
let idx = route.matched_path_index();

future::ok(one(Peek {
Expand Down Expand Up @@ -413,7 +413,7 @@ impl fmt::Debug for Peek {
/// });
/// ```
pub fn full() -> impl Filter<Extract = One<FullPath>, Error = Infallible> + Copy {
filter_fn(move |route| future::ok(one(FullPath(path_and_query(&route)))))
filter_fn(move |route| future::ok(one(FullPath(path_and_query(route)))))
}

/// Represents the full request path, returned by the [`full()`] filter.
Expand All @@ -422,7 +422,7 @@ pub struct FullPath(PathAndQuery);
impl FullPath {
/// Get the `&str` representation of the request path.
pub fn as_str(&self) -> &str {
&self.0.path()
self.0.path()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/filters/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Event {
/// Set Server-sent event retry
/// Retry timeout field ("retry:<timeout>")
pub fn retry(mut self, duration: Duration) -> Event {
self.retry = Some(duration.into());
self.retry = Some(duration);
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/filters/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Ws {
/// Set the maximum frame size (defaults to 16 megabytes)
pub fn max_frame_size(mut self, max: usize) -> Self {
self.config
.get_or_insert_with(|| WebSocketConfig::default())
.get_or_insert_with(WebSocketConfig::default)
.max_frame_size = Some(max);
self
}
Expand Down Expand Up @@ -388,9 +388,9 @@ impl fmt::Debug for Message {
}
}

impl Into<Vec<u8>> for Message {
fn into(self) -> Vec<u8> {
self.into_bytes()
impl From<Message> for Vec<u8> {
fn from(m: Message) -> Self {
m.into_bytes()
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,7 @@ impl Rejection {
/// assert!(rejection.is_not_found());
/// ```
pub fn is_not_found(&self) -> bool {
if let Reason::NotFound = self.reason {
true
} else {
false
}
matches!(self.reason, Reason::NotFound)
}
}

Expand Down
1 change: 0 additions & 1 deletion src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::cell::RefCell;
use std::mem;
use std::net::SocketAddr;

use http;
use hyper::Body;

use crate::Request;
Expand Down
5 changes: 2 additions & 3 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ impl RequestBuilder {
}
};
let (parts, body) = res.into_parts();
hyper::body::to_bytes(body)
.map_ok(|chunk| Response::from_parts(parts, chunk.into()))
hyper::body::to_bytes(body).map_ok(|chunk| Response::from_parts(parts, chunk))
}),
);

Expand Down Expand Up @@ -519,7 +518,7 @@ impl WsBuilder {
let upgrade = ::hyper::Client::builder()
.build(AddrConnect(addr))
.request(req)
.and_then(|res| hyper::upgrade::on(res));
.and_then(hyper::upgrade::on);

let upgraded = match upgrade.await {
Ok(up) => {
Expand Down

0 comments on commit 79e7bba

Please sign in to comment.