rust/library
Matthias Krüger 4aa973b3e4
Rollup merge of #136609 - mammothbane:master, r=scottmcm
libcore/net: `IpAddr::as_octets()`

[ACP](https://github.com/rust-lang/libs-team/issues/535)
[Tracking issue](https://github.com/rust-lang/rust/issues/137259)

Adds `const` `core::net::IpAddr{,v4,v6}::as_octets()` methods to provide reference access to IP address contents.

The concrete usecase for me is allowing the `IpAddr` to provide an extended lifetime in contexts that want a `&[u8]`:

```rust
trait AddrSlice {
    fn addr_slice(&self) -> &[u8];
}

impl AddrSlice for IpAddrV4 {
    fn addr_slice(&self) -> &[u8] {
        // self.octets() doesn't help us here, because we can't return a reference to the owned array.
        // Instead we want the IpAddrV4 to continue owning the memory:
        self.as_octets()
    }
}
```

(Notably, in this case we can't parameterize `AddrSlice` by a `const N: usize` (such that `fn addr_slice(&self) -> [u8; N]`) and maintain object-safety.)
2025-02-21 19:01:13 +01:00
..
alloc Rollup merge of #132268 - elichai:string_try_from_vec, r=Amanieu 2025-02-19 21:16:02 +01:00
backtrace@9d2c34e7e6 Update backtrace 2025-02-13 14:32:50 -08:00
core Rollup merge of #136609 - mammothbane:master, r=scottmcm 2025-02-21 19:01:13 +01:00
coretests Rollup merge of #136148 - kpreid:type-str, r=joboet 2025-02-21 19:01:12 +01:00
panic_abort panic_abort: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
panic_unwind panic_unwind: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
portable-simd Remove ignored #[must_use] attributes from portable-simd 2025-02-12 13:59:22 +01:00
proc_macro proc_macro: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
profiler_builtins compiler & tools dependencies: 2024-12-17 17:41:00 +00:00
rtstartup Mark extern blocks as unsafe 2025-02-09 17:11:13 +00:00
rustc-std-workspace-alloc
rustc-std-workspace-core update rustc-std-workspace crates 2024-11-04 07:45:15 +01:00
rustc-std-workspace-std
std Rollup merge of #136148 - kpreid:type-str, r=joboet 2025-02-21 19:01:12 +01:00
stdarch@684de0d6fe Bump stdarch 2024-12-24 19:00:57 +01:00
sysroot Optionally add type names to TypeIds. 2025-02-11 18:42:19 -08:00
test Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDenton 2025-02-17 06:37:37 +01:00
unwind unwind: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
windows_targets Mark extern blocks as unsafe 2025-02-09 17:11:13 +00:00
Cargo.lock library: Update rand to 0.9.0 2025-02-13 12:20:55 -08:00
Cargo.toml Put all coretests in a separate crate 2025-01-26 10:26:36 +00:00