Skip to content

Commit f1b89c1

Browse files
authored
refactor(client): use Box<str> inside dns::Name (hyperium#2727)
Use Box<str> in hyper::client::connect::dns::Name, so its size is 16 bytes, not 24 bytes. As Name never change its contents, read-only Box<str> is perfectly OK.
1 parent 02f3630 commit f1b89c1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/client/connect/dns.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(super) use self::sealed::Resolve;
3838
/// A domain name to resolve into IP addresses.
3939
#[derive(Clone, Hash, Eq, PartialEq)]
4040
pub struct Name {
41-
host: String,
41+
host: Box<str>,
4242
}
4343

4444
/// A resolver using blocking `getaddrinfo` calls in a threadpool.
@@ -58,7 +58,7 @@ pub struct GaiFuture {
5858
}
5959

6060
impl Name {
61-
pub(super) fn new(host: String) -> Name {
61+
pub(super) fn new(host: Box<str>) -> Name {
6262
Name { host }
6363
}
6464

@@ -85,7 +85,7 @@ impl FromStr for Name {
8585

8686
fn from_str(host: &str) -> Result<Self, Self::Err> {
8787
// Possibly add validation later
88-
Ok(Name::new(host.to_owned()))
88+
Ok(Name::new(host.into()))
8989
}
9090
}
9191

0 commit comments

Comments
 (0)