[GH-ISSUE #1411] Support &String for IntoName #667

Closed
opened 2026-03-15 23:44:30 +03:00 by kerem · 5 comments
Owner

Originally created by @Inrin on GitHub (Mar 14, 2021).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1411

Is your feature request related to a problem? Please describe.
no

Describe the solution you'd like
Implement IntoName Trait for &'a String

Describe alternatives you've considered
Just use:

  1. as_str() or &*foo
  2. Clone the String to not move it.

Additional context
https://docs.rs/trust-dns-resolver/0.20.0/trust_dns_resolver/struct.Resolver.html#method.txt_lookup
implies it behaves like a &str Parameter.

https://docs.rs/trust-dns-resolver/0.20.0/trust_dns_resolver/struct.AsyncResolver.html#method.txt_lookup
just mentions a string

So my first try had been to use: &foo where foo is a String.

Originally created by @Inrin on GitHub (Mar 14, 2021). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1411 **Is your feature request related to a problem? Please describe.** no **Describe the solution you'd like** Implement `IntoName` Trait for `&'a String` **Describe alternatives you've considered** Just use: 1) `as_str()` or `&*foo` 2) Clone the String to not move it. **Additional context** https://docs.rs/trust-dns-resolver/0.20.0/trust_dns_resolver/struct.Resolver.html#method.txt_lookup implies it behaves like a `&str` Parameter. https://docs.rs/trust-dns-resolver/0.20.0/trust_dns_resolver/struct.AsyncResolver.html#method.txt_lookup just mentions *a string* So my first try had been to use: `&foo` where foo is a `String`.
Author
Owner

@bluejekyll commented on GitHub (Mar 14, 2021):

You can use this method: https://doc.rust-lang.org/alloc/string/struct.String.html#method.as_str, though, be aware, &str will still allocate for Name. I think adding the other impl for &String would be fine, but as_str should work in the meantime, right?

<!-- gh-comment-id:798996012 --> @bluejekyll commented on GitHub (Mar 14, 2021): You can use this method: https://doc.rust-lang.org/alloc/string/struct.String.html#method.as_str, though, be aware, `&str` will still allocate for `Name`. I think adding the other impl for `&String` would be fine, but `as_str` should work in the meantime, right?
Author
Owner

@Inrin commented on GitHub (Mar 14, 2021):

Yes sure!
I used as_str() as mentioned in "Describe alternatives you've considered".

This is just a "convenience" feature request ;)

<!-- gh-comment-id:799003108 --> @Inrin commented on GitHub (Mar 14, 2021): Yes sure! I used `as_str()` as mentioned in "Describe alternatives you've considered". This is just a "convenience" feature request ;)
Author
Owner

@bluejekyll commented on GitHub (Mar 14, 2021):

yeah, I saw that. I was confused if that was working as expected or not. We can add that conversion if it simplifies things.

<!-- gh-comment-id:799003406 --> @bluejekyll commented on GitHub (Mar 14, 2021): yeah, I saw that. I was confused if that was working as expected or not. We can add that conversion if it simplifies things.
Author
Owner

@Inrin commented on GitHub (Mar 14, 2021):

Would be nice!
Thank you!

<!-- gh-comment-id:799004441 --> @Inrin commented on GitHub (Mar 14, 2021): Would be nice! Thank you!
Author
Owner

@bluejekyll commented on GitHub (Apr 9, 2021):

Fixed in #1434

<!-- gh-comment-id:816914383 --> @bluejekyll commented on GitHub (Apr 9, 2021): Fixed in #1434
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#667
No description provided.