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(client): small refactoring #88

Merged
merged 3 commits into from
Jan 14, 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
4 changes: 2 additions & 2 deletions src/client/legacy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ where
impl<C: Clone, B> Clone for Client<C, B> {
fn clone(&self) -> Client<C, B> {
Client {
config: self.config.clone(),
config: self.config,
exec: self.exec.clone(),
#[cfg(feature = "http1")]
h1_builder: self.h1_builder.clone(),
Expand Down Expand Up @@ -925,7 +925,7 @@ fn set_scheme(uri: &mut Uri, scheme: Scheme) {
uri.scheme().is_none(),
"set_scheme expects no existing scheme"
);
let old = std::mem::replace(uri, Uri::default());
let old = std::mem::take(uri);
let mut parts: ::http::uri::Parts = old.into();
parts.scheme = Some(scheme);
parts.path_and_query = Some("/".parse().expect("slash is a valid path"));
Expand Down
4 changes: 1 addition & 3 deletions src/client/legacy/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,7 @@ struct ConnectingTcpRemote {

impl ConnectingTcpRemote {
fn new(addrs: dns::SocketAddrs, connect_timeout: Option<Duration>) -> Self {
let connect_timeout = connect_timeout
.map(|t| t.checked_div(addrs.len() as u32))
.flatten();
let connect_timeout = connect_timeout.and_then(|t| t.checked_div(addrs.len() as u32));

Self {
addrs,
Expand Down
2 changes: 1 addition & 1 deletion src/client/legacy/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl<T: Poolable, K: Key> PoolInner<T, K> {
Some(value) => {
// borrow-check scope...
{
let idle_list = self.idle.entry(key.clone()).or_insert_with(Vec::new);
let idle_list = self.idle.entry(key.clone()).or_default();
if self.max_idle_per_host <= idle_list.len() {
trace!("max idle per host for {:?}, dropping connection", key);
return;
Expand Down
8 changes: 2 additions & 6 deletions src/server/conn/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ pub struct Http1Builder<'a, E> {
impl<E> Http1Builder<'_, E> {
/// Http2 configuration.
pub fn http2(&mut self) -> Http2Builder<'_, E> {
Http2Builder {
inner: &mut self.inner,
}
Http2Builder { inner: self.inner }
}

/// Set whether HTTP/1 connections should support half-closures.
Expand Down Expand Up @@ -546,9 +544,7 @@ pub struct Http2Builder<'a, E> {
impl<E> Http2Builder<'_, E> {
/// Http1 configuration.
pub fn http1(&mut self) -> Http1Builder<'_, E> {
Http1Builder {
inner: &mut self.inner,
}
Http1Builder { inner: self.inner }
}

/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
Expand Down