Skip to content

feat: more from impls for ServerName and IpAddr#55

Merged
djc merged 1 commit intorustls:mainfrom
nanoqsh:main
Sep 22, 2024
Merged

feat: more from impls for ServerName and IpAddr#55
djc merged 1 commit intorustls:mainfrom
nanoqsh:main

Conversation

@nanoqsh
Copy link
Contributor

@nanoqsh nanoqsh commented Sep 22, 2024

Let's add more convenient From impls.

Now instead of:

let name = ServerName::IpAddress(IpAddr::V4(Ipv4Addr::LOCALHOST).into());

You can write:

let name = ServerName::from(Ipv4Addr::LOCALHOST);

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, thanks!

@djc
Copy link
Member

djc commented Sep 22, 2024

Reminder that while core::net now contains IpAddr et al, that's a relatively recent development as of 1.77.0, which is why, given our MSRV, we still need to duplicate a bunch of stuff here and guard trait impls with std here.

Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is a nice quality of life boost.

@djc djc added this pull request to the merge queue Sep 22, 2024
Merged via the queue into rustls:main with commit bd6a082 Sep 22, 2024
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