A few ergonomic From impls for SocketAddr/IpAddr#39372
A few ergonomic From impls for SocketAddr/IpAddr#39372bors merged 2 commits intorust-lang:masterfrom
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
I wonder if something like impl<T: Into<Ipv4Addr>> From<T> for IpAddr { ... }would be at odds with the coherence. |
|
@nagisa I considered it, but also worried about the possibility of some type |
|
For completion, can you add implementations for |
|
@clarcharr implementations for |
|
I worry slightly that this seems "too clever" but we've got precedent elsewhere in the standard library for working with @rfcbot fcp merge |
|
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
This is cool! 👍 from me. |
src/libstd/net/ip.rs
Outdated
There was a problem hiding this comment.
Tiny correction: this should say segments instead of octects.
63cb2ad to
cd603e4
Compare
|
ping @BurntSushi, @brson (checkboxes) |
|
@bors: r+ |
|
📌 Commit cd603e4 has been approved by |
…crichton A few ergonomic From impls for SocketAddr/IpAddr My main motivation is removing things like this: `"127.0.0.1:3000".parse().unwrap()`. Instead, this now works: `SocketAddr::from(([127, 0, 0, 1], 3000))` or even `([127, 0, 0, 1], 3000).into())` when passing to a function.
…crichton A few ergonomic From impls for SocketAddr/IpAddr My main motivation is removing things like this: `"127.0.0.1:3000".parse().unwrap()`. Instead, this now works: `SocketAddr::from(([127, 0, 0, 1], 3000))` or even `([127, 0, 0, 1], 3000).into())` when passing to a function.
My main motivation is removing things like this:
"127.0.0.1:3000".parse().unwrap(). Instead, this now works:SocketAddr::from(([127, 0, 0, 1], 3000))or even([127, 0, 0, 1], 3000).into())when passing to a function.