-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Tracking issue for IP constructors #44582
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Is there any way to implement these as I personally don't like this kind of trivial function. |
See also #39819 |
I’d also like these to be associated
If we’re doing down this road, it seems like many more APIs should also be @rust-lang/libs what do you think? |
I think I'd prefer these to be associated consts as well. We don't necessarily need to make all of those functions const as well - we can just directly initialize the structures. |
Hmm yes, I suppose we could replace the |
Maybe I'm missing something, but aren't IP addresses independent of endianness? In other words, aren't they |
An |
Right. |
OK, thanks for explaining! An alternative would be to just |
I think I’d prefer this over transmute: Ipv4Addr {
inner: c::in_addr {
// 127.0.0.1
#[cfg(target_endian = "big")]
s_addr: 0x7F_00_00_01_u32,
#[cfg(target_endian = "little")]
s_addr: 0x01_00_00_7F_u32,
}
} (Either way, with an |
The libs team discussed this and the consensus was to stabilize this as associated constants (in uppercase: @rfcbot fcp merge |
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), 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 now entering its final comment period, as per the review above. 🔔 |
I started working on changing this to associated constants, but ran into a bit of a roadblock. |
hmm, actually it looks like the non-public field is just used for alignment. Maybe now that |
@tmccombs Maybe add |
This allows constructiong in6_addr instances as a constant from other crates. See rust-lang/rust#44582 (comment)
This allows constructiong in6_addr instances as a constant from other crates. See rust-lang/rust#44582 (comment)
For unix at least, in6_addr comes from the libc crate. Which it looks like has to support older versions of rust. So even when Similarly I don't think I can add |
The final comment period is now complete. |
I just got PR #51171 merged making the compiler intrinsics for endianess conversion ( For |
And I don't think it can be, unless it is a compiler intrinsic. And the Ipv4Addr is currently doable (although having a const |
I implemented this (and a bit more) in #52872 |
…TimNN Make IpvXAddr::new const fns and the well known addresses associated constants Implements/fixes rust-lang#44582 I just got a PR towards libc (rust-lang/libc#1044) merged. With the new feature added in that PR it is now possible to create `in6_addr` instances as consts. This enables us to finally make the constructors of the IP structs const fns and to make the localhost/unspecified addresses associated constants, as agreed in the above mentioned tracking issue. I also added a BROADCAST constant. Personally this is the well known address I tend to need the most often.
Make IpvXAddr::new const fns and the well known addresses associated constants Implements/fixes #44582 I just got a PR towards libc (rust-lang/libc#1044) merged. With the new feature added in that PR it is now possible to create `in6_addr` instances as consts. This enables us to finally make the constructors of the IP structs const fns and to make the localhost/unspecified addresses associated constants, as agreed in the above mentioned tracking issue. I also added a BROADCAST constant. Personally this is the well known address I tend to need the most often.
Make IpvXAddr::new const fns and the well known addresses associated constants Implements/fixes #44582 I just got a PR towards libc (rust-lang/libc#1044) merged. With the new feature added in that PR it is now possible to create `in6_addr` instances as consts. This enables us to finally make the constructors of the IP structs const fns and to make the localhost/unspecified addresses associated constants, as agreed in the above mentioned tracking issue. I also added a BROADCAST constant. Personally this is the well known address I tend to need the most often.
This should probably not have been closed 🙈 It was me invalidly writing Anyway. Now that this is merged, all that should be left is to mark the constants as stable I guess. |
Reopening to track stabilization. |
I should point out that I also added
|
I created a PR to stabilize (including BROADCAST) but can change it if that isn't desired. |
…odrAus Stabilize IP associated constants Fixes rust-lang#44582
Tracking issue for IP address convenience constructors, added in #44395, modified in #52872.
The text was updated successfully, but these errors were encountered: