mirror of
https://github.com/actix/actix-web.git
synced 2024-11-29 04:51:13 +00:00
clippy
This commit is contained in:
parent
0c144054cb
commit
3d621677a5
6 changed files with 18 additions and 14 deletions
|
@ -75,7 +75,7 @@ pub(crate) fn directory_listing(
|
||||||
if dir.is_visible(&entry) {
|
if dir.is_visible(&entry) {
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
let p = match entry.path().strip_prefix(&dir.path) {
|
let p = match entry.path().strip_prefix(&dir.path) {
|
||||||
Ok(p) if cfg!(windows) => base.join(p).to_string_lossy().replace("\\", "/"),
|
Ok(p) if cfg!(windows) => base.join(p).to_string_lossy().replace('\\', "/"),
|
||||||
Ok(p) => base.join(p).to_string_lossy().into_owned(),
|
Ok(p) => base.join(p).to_string_lossy().into_owned(),
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
|
@ -128,7 +128,10 @@ impl Decoder for ClientCodec {
|
||||||
type Error = ParseError;
|
type Error = ParseError;
|
||||||
|
|
||||||
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
|
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
|
||||||
debug_assert!(!self.inner.payload.is_some(), "Payload decoder is set");
|
debug_assert!(
|
||||||
|
self.inner.payload.is_none(),
|
||||||
|
"Payload decoder should not be set"
|
||||||
|
);
|
||||||
|
|
||||||
if let Some((req, payload)) = self.inner.decoder.decode(src)? {
|
if let Some((req, payload)) = self.inner.decoder.decode(src)? {
|
||||||
if let Some(conn_type) = req.conn_type() {
|
if let Some(conn_type) = req.conn_type() {
|
||||||
|
|
|
@ -145,7 +145,8 @@ macro_rules! register {
|
||||||
concat!("/user/keys"),
|
concat!("/user/keys"),
|
||||||
concat!("/user/keys/", $p1),
|
concat!("/user/keys/", $p1),
|
||||||
];
|
];
|
||||||
std::array::IntoIter::new(arr)
|
|
||||||
|
IntoIterator::into_iter(arr)
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +159,7 @@ fn call() -> impl Iterator<Item = &'static str> {
|
||||||
"/repos/rust-lang/rust/releases/1.51.0",
|
"/repos/rust-lang/rust/releases/1.51.0",
|
||||||
];
|
];
|
||||||
|
|
||||||
std::array::IntoIter::new(arr)
|
IntoIterator::into_iter(arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_routers(c: &mut Criterion) {
|
fn compare_routers(c: &mut Criterion) {
|
||||||
|
|
|
@ -898,7 +898,7 @@ impl ResourceDef {
|
||||||
}
|
}
|
||||||
|
|
||||||
let pattern_re_set = RegexSet::new(re_set).unwrap();
|
let pattern_re_set = RegexSet::new(re_set).unwrap();
|
||||||
let segments = segments.unwrap_or_else(Vec::new);
|
let segments = segments.unwrap_or_default();
|
||||||
|
|
||||||
(
|
(
|
||||||
PatternType::DynamicSet(pattern_re_set, pattern_data),
|
PatternType::DynamicSet(pattern_re_set, pattern_data),
|
||||||
|
|
|
@ -62,18 +62,18 @@ crate::http::header::common_header! {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use actix_http::test::TestRequest;
|
||||||
|
|
||||||
use super::IfNoneMatch;
|
use super::IfNoneMatch;
|
||||||
use crate::http::header::{EntityTag, Header, IF_NONE_MATCH};
|
use crate::http::header::{EntityTag, Header, IF_NONE_MATCH};
|
||||||
use actix_http::test::TestRequest;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_if_none_match() {
|
fn test_if_none_match() {
|
||||||
let mut if_none_match: Result<IfNoneMatch, _>;
|
|
||||||
|
|
||||||
let req = TestRequest::default()
|
let req = TestRequest::default()
|
||||||
.insert_header((IF_NONE_MATCH, "*"))
|
.insert_header((IF_NONE_MATCH, "*"))
|
||||||
.finish();
|
.finish();
|
||||||
if_none_match = Header::parse(&req);
|
|
||||||
|
let mut if_none_match = IfNoneMatch::parse(&req);
|
||||||
assert_eq!(if_none_match.ok(), Some(IfNoneMatch::Any));
|
assert_eq!(if_none_match.ok(), Some(IfNoneMatch::Any));
|
||||||
|
|
||||||
let req = TestRequest::default()
|
let req = TestRequest::default()
|
||||||
|
|
|
@ -337,7 +337,7 @@ where
|
||||||
match self.get_mut() {
|
match self.get_mut() {
|
||||||
Connection::Tcp(ConnectionType::H1(conn)) => Pin::new(conn).poll_write(cx, buf),
|
Connection::Tcp(ConnectionType::H1(conn)) => Pin::new(conn).poll_write(cx, buf),
|
||||||
Connection::Tls(ConnectionType::H1(conn)) => Pin::new(conn).poll_write(cx, buf),
|
Connection::Tls(ConnectionType::H1(conn)) => Pin::new(conn).poll_write(cx, buf),
|
||||||
_ => unreachable!(H2_UNREACHABLE_WRITE),
|
_ => unreachable!("{}", H2_UNREACHABLE_WRITE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ where
|
||||||
match self.get_mut() {
|
match self.get_mut() {
|
||||||
Connection::Tcp(ConnectionType::H1(conn)) => Pin::new(conn).poll_flush(cx),
|
Connection::Tcp(ConnectionType::H1(conn)) => Pin::new(conn).poll_flush(cx),
|
||||||
Connection::Tls(ConnectionType::H1(conn)) => Pin::new(conn).poll_flush(cx),
|
Connection::Tls(ConnectionType::H1(conn)) => Pin::new(conn).poll_flush(cx),
|
||||||
_ => unreachable!(H2_UNREACHABLE_WRITE),
|
_ => unreachable!("{}", H2_UNREACHABLE_WRITE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ where
|
||||||
match self.get_mut() {
|
match self.get_mut() {
|
||||||
Connection::Tcp(ConnectionType::H1(conn)) => Pin::new(conn).poll_shutdown(cx),
|
Connection::Tcp(ConnectionType::H1(conn)) => Pin::new(conn).poll_shutdown(cx),
|
||||||
Connection::Tls(ConnectionType::H1(conn)) => Pin::new(conn).poll_shutdown(cx),
|
Connection::Tls(ConnectionType::H1(conn)) => Pin::new(conn).poll_shutdown(cx),
|
||||||
_ => unreachable!(H2_UNREACHABLE_WRITE),
|
_ => unreachable!("{}", H2_UNREACHABLE_WRITE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ where
|
||||||
Connection::Tls(ConnectionType::H1(conn)) => {
|
Connection::Tls(ConnectionType::H1(conn)) => {
|
||||||
Pin::new(conn).poll_write_vectored(cx, bufs)
|
Pin::new(conn).poll_write_vectored(cx, bufs)
|
||||||
}
|
}
|
||||||
_ => unreachable!(H2_UNREACHABLE_WRITE),
|
_ => unreachable!("{}", H2_UNREACHABLE_WRITE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ where
|
||||||
match *self {
|
match *self {
|
||||||
Connection::Tcp(ConnectionType::H1(ref conn)) => conn.is_write_vectored(),
|
Connection::Tcp(ConnectionType::H1(ref conn)) => conn.is_write_vectored(),
|
||||||
Connection::Tls(ConnectionType::H1(ref conn)) => conn.is_write_vectored(),
|
Connection::Tls(ConnectionType::H1(ref conn)) => conn.is_write_vectored(),
|
||||||
_ => unreachable!(H2_UNREACHABLE_WRITE),
|
_ => unreachable!("{}", H2_UNREACHABLE_WRITE),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue