From f1b89c117cffebed4b2b8eb2d221fd9b25c1d3d1 Mon Sep 17 00:00:00 2001 From: Ivan Boldyrev Date: Wed, 29 Dec 2021 19:33:06 +0300 Subject: [PATCH] refactor(client): use `Box` inside `dns::Name` (#2727) Use Box in hyper::client::connect::dns::Name, so its size is 16 bytes, not 24 bytes. As Name never change its contents, read-only Box is perfectly OK. --- src/client/connect/dns.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/connect/dns.rs b/src/client/connect/dns.rs index 968d8567cb..e4465078b3 100644 --- a/src/client/connect/dns.rs +++ b/src/client/connect/dns.rs @@ -38,7 +38,7 @@ pub(super) use self::sealed::Resolve; /// A domain name to resolve into IP addresses. #[derive(Clone, Hash, Eq, PartialEq)] pub struct Name { - host: String, + host: Box, } /// A resolver using blocking `getaddrinfo` calls in a threadpool. @@ -58,7 +58,7 @@ pub struct GaiFuture { } impl Name { - pub(super) fn new(host: String) -> Name { + pub(super) fn new(host: Box) -> Name { Name { host } } @@ -85,7 +85,7 @@ impl FromStr for Name { fn from_str(host: &str) -> Result { // Possibly add validation later - Ok(Name::new(host.to_owned())) + Ok(Name::new(host.into())) } }