mirror of
https://github.com/ntex-rs/ntex-extras.git
synced 2025-04-03 04:47:40 +03:00
clippy
This commit is contained in:
parent
2abe40fdf6
commit
fe92ba2e8c
4 changed files with 11 additions and 14 deletions
|
@ -38,7 +38,7 @@ impl WebResponseError<DefaultError> for FilesError {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Display, Debug, PartialEq)]
|
||||
#[derive(Display, Debug, PartialEq, Eq)]
|
||||
pub enum UriSegmentError {
|
||||
/// The segment started with the wrapped invalid character.
|
||||
#[display(fmt = "The segment started with the wrapped invalid character")]
|
||||
|
|
|
@ -91,8 +91,8 @@ impl Stream for ChunkedReadFile {
|
|||
let mut file = self.file.take().expect("Use after completion");
|
||||
self.fut = Some(
|
||||
web::block(move || {
|
||||
let max_bytes: usize;
|
||||
max_bytes = cmp::min(size.saturating_sub(counter), 65_536) as usize;
|
||||
let max_bytes: usize =
|
||||
cmp::min(size.saturating_sub(counter), 65_536) as usize;
|
||||
let mut buf = Vec::with_capacity(max_bytes);
|
||||
file.seek(io::SeekFrom::Start(offset))?;
|
||||
let nbytes = file.by_ref().take(max_bytes as u64).read_to_end(&mut buf)?;
|
||||
|
@ -165,7 +165,7 @@ fn directory_listing(dir: &Directory, req: &HttpRequest) -> Result<WebResponse,
|
|||
if dir.is_visible(&entry) {
|
||||
let entry = entry.unwrap();
|
||||
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(),
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
@ -419,7 +419,7 @@ where
|
|||
guards: self.guards.clone(),
|
||||
};
|
||||
|
||||
if let Some(ref default) = self.default.as_ref() {
|
||||
if let Some(default) = self.default.as_ref() {
|
||||
default
|
||||
.new_service(())
|
||||
.map(move |result| match result {
|
||||
|
@ -491,10 +491,7 @@ where
|
|||
(**guard).check(req.head())
|
||||
} else {
|
||||
// default behaviour
|
||||
match *req.method() {
|
||||
Method::HEAD | Method::GET => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(*req.method(), Method::HEAD | Method::GET)
|
||||
};
|
||||
|
||||
if !is_method_valid {
|
||||
|
|
|
@ -295,8 +295,8 @@ impl NamedFile {
|
|||
|
||||
(last_modified, header)
|
||||
} {
|
||||
let t1: SystemTime = m.clone().into();
|
||||
let t2: SystemTime = since.clone().into();
|
||||
let t1: SystemTime = (*m).into();
|
||||
let t2: SystemTime = (*since).into();
|
||||
match (t1.duration_since(UNIX_EPOCH), t2.duration_since(UNIX_EPOCH)) {
|
||||
(Ok(t1), Ok(t2)) => t1 > t2,
|
||||
_ => false,
|
||||
|
@ -322,8 +322,8 @@ impl NamedFile {
|
|||
}
|
||||
(last_modified, header)
|
||||
} {
|
||||
let t1: SystemTime = m.clone().into();
|
||||
let t2: SystemTime = since.clone().into();
|
||||
let t1: SystemTime = (*m).into();
|
||||
let t2: SystemTime = (*since).into();
|
||||
match (t1.duration_since(UNIX_EPOCH), t2.duration_since(UNIX_EPOCH)) {
|
||||
(Ok(t1), Ok(t2)) => t1 <= t2,
|
||||
_ => false,
|
||||
|
|
|
@ -80,7 +80,7 @@ impl HttpRange {
|
|||
})
|
||||
.collect::<Result<_, _>>()?;
|
||||
|
||||
let ranges: Vec<HttpRange> = all_ranges.into_iter().filter_map(|x| x).collect();
|
||||
let ranges: Vec<HttpRange> = all_ranges.into_iter().flatten().collect();
|
||||
|
||||
if no_overlap && ranges.is_empty() {
|
||||
return Err(());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue