mirror of
https://github.com/fafhrd91/actix-web
synced 2025-02-22 12:13:16 +01:00
clippy
This commit is contained in:
parent
a0c0bff944
commit
5f412c67db
@ -21,6 +21,7 @@ impl ResponseError for FilesError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
#[derive(Display, Debug, PartialEq)]
|
#[derive(Display, Debug, PartialEq)]
|
||||||
pub enum UriSegmentError {
|
pub enum UriSegmentError {
|
||||||
/// The segment started with the wrapped invalid character.
|
/// The segment started with the wrapped invalid character.
|
||||||
|
@ -684,7 +684,7 @@ impl<'a> Iterator for Iter<'a> {
|
|||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
// handle in-progress multi value lists first
|
// handle in-progress multi value lists first
|
||||||
if let Some((ref name, ref mut vals)) = self.multi_inner {
|
if let Some((name, ref mut vals)) = self.multi_inner {
|
||||||
match vals.get(self.multi_idx) {
|
match vals.get(self.multi_idx) {
|
||||||
Some(val) => {
|
Some(val) => {
|
||||||
self.multi_idx += 1;
|
self.multi_idx += 1;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
//! [rustls]: https://crates.io/crates/rustls
|
//! [rustls]: https://crates.io/crates/rustls
|
||||||
//! [trust-dns]: https://crates.io/crates/trust-dns
|
//! [trust-dns]: https://crates.io/crates/trust-dns
|
||||||
|
|
||||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
#![deny(rust_2018_idioms, nonstandard_style, clippy::uninit_assumed_init)]
|
||||||
#![allow(
|
#![allow(
|
||||||
clippy::type_complexity,
|
clippy::type_complexity,
|
||||||
clippy::too_many_arguments,
|
clippy::too_many_arguments,
|
||||||
|
@ -209,7 +209,7 @@ impl RequestHeadType {
|
|||||||
impl AsRef<RequestHead> for RequestHeadType {
|
impl AsRef<RequestHead> for RequestHeadType {
|
||||||
fn as_ref(&self) -> &RequestHead {
|
fn as_ref(&self) -> &RequestHead {
|
||||||
match self {
|
match self {
|
||||||
RequestHeadType::Owned(head) => &head,
|
RequestHeadType::Owned(head) => head,
|
||||||
RequestHeadType::Rc(head, _) => head.as_ref(),
|
RequestHeadType::Rc(head, _) => head.as_ref(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ impl<T: Head> std::ops::Deref for Message<T> {
|
|||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.head.as_ref()
|
self.head.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ impl<T: ResourcePath> Path<T> {
|
|||||||
for (seg_name, val) in self.segments.iter() {
|
for (seg_name, val) in self.segments.iter() {
|
||||||
if name == seg_name {
|
if name == seg_name {
|
||||||
return match val {
|
return match val {
|
||||||
PathItem::Static(ref s) => Some(&s),
|
PathItem::Static(ref s) => Some(s),
|
||||||
PathItem::Segment(s, e) => {
|
PathItem::Segment(s, e) => {
|
||||||
Some(&self.path.path()[(*s as usize)..(*e as usize)])
|
Some(&self.path.path()[(*s as usize)..(*e as usize)])
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ impl<'a, T: ResourcePath> Iterator for PathIter<'a, T> {
|
|||||||
if self.idx < self.params.segment_count() {
|
if self.idx < self.params.segment_count() {
|
||||||
let idx = self.idx;
|
let idx = self.idx;
|
||||||
let res = match self.params.segments[idx].1 {
|
let res = match self.params.segments[idx].1 {
|
||||||
PathItem::Static(ref s) => &s,
|
PathItem::Static(ref s) => s,
|
||||||
PathItem::Segment(s, e) => &self.params.path.path()[(s as usize)..(e as usize)],
|
PathItem::Segment(s, e) => &self.params.path.path()[(s as usize)..(e as usize)],
|
||||||
};
|
};
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
@ -207,7 +207,7 @@ impl<T: ResourcePath> Index<usize> for Path<T> {
|
|||||||
|
|
||||||
fn index(&self, idx: usize) -> &str {
|
fn index(&self, idx: usize) -> &str {
|
||||||
match self.segments[idx].1 {
|
match self.segments[idx].1 {
|
||||||
PathItem::Static(ref s) => &s,
|
PathItem::Static(ref s) => s,
|
||||||
PathItem::Segment(s, e) => &self.path.path()[(s as usize)..(e as usize)],
|
PathItem::Segment(s, e) => &self.path.path()[(s as usize)..(e as usize)],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ impl ResourceDef {
|
|||||||
let mut pattern_data = Vec::new();
|
let mut pattern_data = Vec::new();
|
||||||
|
|
||||||
for pattern in &patterns {
|
for pattern in &patterns {
|
||||||
match ResourceDef::parse(&pattern, false, true) {
|
match ResourceDef::parse(pattern, false, true) {
|
||||||
(PatternType::Dynamic(re, names), _) => {
|
(PatternType::Dynamic(re, names), _) => {
|
||||||
re_set.push(re.as_str().to_owned());
|
re_set.push(re.as_str().to_owned());
|
||||||
pattern_data.push((re, names));
|
pattern_data.push((re, names));
|
||||||
@ -790,7 +790,7 @@ impl ResourceDef {
|
|||||||
profile_section!(pattern_dynamic_extract_captures);
|
profile_section!(pattern_dynamic_extract_captures);
|
||||||
|
|
||||||
for (no, name) in names.iter().enumerate() {
|
for (no, name) in names.iter().enumerate() {
|
||||||
if let Some(m) = captures.name(&name) {
|
if let Some(m) = captures.name(name) {
|
||||||
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
||||||
} else {
|
} else {
|
||||||
log::error!(
|
log::error!(
|
||||||
@ -820,7 +820,7 @@ impl ResourceDef {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (no, name) in names.iter().enumerate() {
|
for (no, name) in names.iter().enumerate() {
|
||||||
if let Some(m) = captures.name(&name) {
|
if let Some(m) = captures.name(name) {
|
||||||
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
segments[no] = PathItem::Segment(m.start() as u16, m.end() as u16);
|
||||||
} else {
|
} else {
|
||||||
log::error!("Dynamic path match but not all segments found: {}", name);
|
log::error!("Dynamic path match but not all segments found: {}", name);
|
||||||
|
@ -457,7 +457,7 @@ impl Header for ContentDisposition {
|
|||||||
|
|
||||||
fn parse<T: crate::HttpMessage>(msg: &T) -> Result<Self, crate::error::ParseError> {
|
fn parse<T: crate::HttpMessage>(msg: &T) -> Result<Self, crate::error::ParseError> {
|
||||||
if let Some(h) = msg.headers().get(&Self::name()) {
|
if let Some(h) = msg.headers().get(&Self::name()) {
|
||||||
Self::from_raw(&h)
|
Self::from_raw(h)
|
||||||
} else {
|
} else {
|
||||||
Err(crate::error::ParseError::Header)
|
Err(crate::error::ParseError::Header)
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,7 @@ impl FormatText {
|
|||||||
*self = FormatText::Str(s.to_string());
|
*self = FormatText::Str(s.to_string());
|
||||||
}
|
}
|
||||||
FormatText::RemoteAddr => {
|
FormatText::RemoteAddr => {
|
||||||
let s = if let Some(ref peer) = req.connection_info().remote_addr() {
|
let s = if let Some(peer) = req.connection_info().remote_addr() {
|
||||||
FormatText::Str((*peer).to_string())
|
FormatText::Str((*peer).to_string())
|
||||||
} else {
|
} else {
|
||||||
FormatText::Str("-".to_string())
|
FormatText::Str("-".to_string())
|
||||||
|
@ -184,7 +184,7 @@ impl HttpRequest {
|
|||||||
U: IntoIterator<Item = I>,
|
U: IntoIterator<Item = I>,
|
||||||
I: AsRef<str>,
|
I: AsRef<str>,
|
||||||
{
|
{
|
||||||
self.resource_map().url_for(&self, name, elements)
|
self.resource_map().url_for(self, name, elements)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate url for named resource
|
/// Generate url for named resource
|
||||||
@ -199,7 +199,7 @@ impl HttpRequest {
|
|||||||
#[inline]
|
#[inline]
|
||||||
/// Get a reference to a `ResourceMap` of current application.
|
/// Get a reference to a `ResourceMap` of current application.
|
||||||
pub fn resource_map(&self) -> &ResourceMap {
|
pub fn resource_map(&self) -> &ResourceMap {
|
||||||
&self.app_state().rmap()
|
self.app_state().rmap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Peer socket address.
|
/// Peer socket address.
|
||||||
|
@ -117,7 +117,7 @@ impl ServiceRequest {
|
|||||||
/// This method returns reference to the request head
|
/// This method returns reference to the request head
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn head(&self) -> &RequestHead {
|
pub fn head(&self) -> &RequestHead {
|
||||||
&self.req.head()
|
self.req.head()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This method returns reference to the request head
|
/// This method returns reference to the request head
|
||||||
|
@ -253,7 +253,7 @@ where
|
|||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
let fallback = bytes.clone();
|
let fallback = bytes.clone();
|
||||||
let left =
|
let left =
|
||||||
L::from_request(&this.req, &mut payload_from_bytes(bytes));
|
L::from_request(this.req, &mut payload_from_bytes(bytes));
|
||||||
EitherExtractState::Left { left, fallback }
|
EitherExtractState::Left { left, fallback }
|
||||||
}
|
}
|
||||||
Err(err) => break Err(EitherExtractError::Bytes(err)),
|
Err(err) => break Err(EitherExtractError::Bytes(err)),
|
||||||
@ -265,7 +265,7 @@ where
|
|||||||
Ok(extracted) => break Ok(Either::Left(extracted)),
|
Ok(extracted) => break Ok(Either::Left(extracted)),
|
||||||
Err(left_err) => {
|
Err(left_err) => {
|
||||||
let right = R::from_request(
|
let right = R::from_request(
|
||||||
&this.req,
|
this.req,
|
||||||
&mut payload_from_bytes(mem::take(fallback)),
|
&mut payload_from_bytes(mem::take(fallback)),
|
||||||
);
|
);
|
||||||
EitherExtractState::Right {
|
EitherExtractState::Right {
|
||||||
|
@ -425,7 +425,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let json = serde_json::from_slice::<T>(&buf)
|
let json = serde_json::from_slice::<T>(buf)
|
||||||
.map_err(JsonPayloadError::Deserialize)?;
|
.map_err(JsonPayloadError::Deserialize)?;
|
||||||
return Poll::Ready(Ok(json));
|
return Poll::Ready(Ok(json));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user