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

Allow constructing ServerName from String #19

Closed
wants to merge 1 commit into from

Conversation

Keruspe
Copy link

@Keruspe Keruspe commented Dec 5, 2023

Split the common part out of TryFrom<&str> and allow constructing a ServerName<'static> from a String like we do for DnsName when alloc feature is enabled.

This is useful when the domain name we want to connect to comes from an environmental source

Split the common part out of TryFrom<&str> and allow constructing a ServerName<'static> from a String like we do for DnsName when alloc feature is enabled
@cpu
Copy link
Member

cpu commented Dec 5, 2023

allow constructing a ServerName<'static> from a String

Isn't this possible with the current API?

let servername = ServerName::try_from(my_string.as_str()).unwrap().to_owned();

Maybe there's a docs update to be done to make that pattern more discoverable.

@Keruspe
Copy link
Author

Keruspe commented Dec 5, 2023

Oh, I totally missed the to_owned, you're right

@Keruspe Keruspe closed this Dec 5, 2023
@Keruspe Keruspe deleted the servername branch December 5, 2023 16:14
@djc
Copy link
Member

djc commented Dec 5, 2023

That will make an extra allocation though, so it's less efficient?

@cpu
Copy link
Member

cpu commented Dec 5, 2023

Check out #21 and 1.0.1 - it should make this more ergonomic/easier to discover.

Thanks for raising the issue/opening a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants