Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(lib): apply small refactoring #697

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/header/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,12 +705,12 @@ impl<T> HeaderMap<T> {
.entries
.len()
.checked_add(additional)
.ok_or_else(|| MaxSizeReached::new())?;
.ok_or_else(MaxSizeReached::new)?;

if cap > self.indices.len() {
let cap = cap
.checked_next_power_of_two()
.ok_or_else(|| MaxSizeReached::new())?;
.ok_or_else(MaxSizeReached::new)?;
if cap > MAX_SIZE {
return Err(MaxSizeReached::new());
}
Expand Down Expand Up @@ -1066,7 +1066,7 @@ impl<T> HeaderMap<T> {
} else {
ValueIter {
map: self,
index: ::std::usize::MAX,
index: usize::MAX,
front: None,
back: None,
}
Expand Down Expand Up @@ -1449,9 +1449,9 @@ impl<T> HeaderMap<T> {
}

#[inline]
fn find<K: ?Sized>(&self, key: &K) -> Option<(usize, usize)>
fn find<K>(&self, key: &K) -> Option<(usize, usize)>
where
K: Hash + Into<HeaderName>,
K: Hash + Into<HeaderName> + ?Sized,
HeaderName: PartialEq<K>,
{
if self.entries.is_empty() {
Expand Down Expand Up @@ -3603,9 +3603,9 @@ fn probe_distance(mask: Size, hash: HashValue, current: usize) -> usize {
current.wrapping_sub(desired_pos(mask, hash)) & mask as usize
}

fn hash_elem_using<K: ?Sized>(danger: &Danger, k: &K) -> HashValue
fn hash_elem_using<K>(danger: &Danger, k: &K) -> HashValue
where
K: Hash,
K: Hash + ?Sized,
{
use fnv::FnvHasher;

Expand Down Expand Up @@ -3838,7 +3838,7 @@ mod as_header_name {
impl Sealed for String {
#[inline]
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, TryEntryError> {
Ok(self.as_str().try_entry(map)?)
self.as_str().try_entry(map)
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/header/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ impl HeaderName {
// https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html#panic-in-const-contexts
//
// See the panics section of this method's document for details.
#[allow(clippy::no_effect)]
#[allow(clippy::no_effect, clippy::out_of_bounds_indexing)]
([] as [u8; 0])[0]; // Invalid header name
}

Expand Down
2 changes: 1 addition & 1 deletion src/header/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl HeaderValue {
// https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html#panic-in-const-contexts
//
// See the panics section of this method's document for details.
#[allow(clippy::no_effect)]
#[allow(clippy::no_effect, clippy::out_of_bounds_indexing)]
([] as [u8; 0])[0]; // Invalid header value
}
i += 1;
Expand Down
2 changes: 1 addition & 1 deletion src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use std::convert::TryFrom;
use bytes::Bytes;

use std::error::Error;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::str::{self, FromStr};
use std::{fmt, u16, u8};

use self::scheme::Scheme2;

Expand Down
2 changes: 1 addition & 1 deletion src/uri/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct PathAndQuery {
pub(super) query: u16,
}

const NONE: u16 = ::std::u16::MAX;
const NONE: u16 = u16::MAX;

impl PathAndQuery {
// Not public while `bytes` is unstable.
Expand Down