diff --git a/CHANGELOG.md b/CHANGELOG.md index ef544e1..fd54447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.4.2 (2025-09-21) +### Added +- `Array::slice_as_flattened(_mut)` ([#142]) + +[#142]: https://github.com/RustCrypto/hybrid-array/pull/142 + ## 0.4.1 (2025-09-10) ### Changed - Make slice conversions `const fn` ([#140]) diff --git a/Cargo.lock b/Cargo.lock index 9adbdf3..16acac5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" [[package]] name = "hybrid-array" -version = "0.4.1" +version = "0.4.2" dependencies = [ "bincode", "bytemuck", diff --git a/Cargo.toml b/Cargo.toml index c483716..b42cfef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hybrid-array" -version = "0.4.1" +version = "0.4.2" description = """ Hybrid typenum-based and const generic array types designed to provide the flexibility of typenum-based expressions while also allowing interoperability diff --git a/src/lib.rs b/src/lib.rs index b5288eb..15bab70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -400,6 +400,18 @@ where // SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]` unsafe { slice::from_raw_parts_mut(slice.as_mut_ptr().cast(), slice.len()) } } + + /// Obtain a flattened slice from a slice of array chunks. + #[inline] + pub fn slice_as_flattened(slice: &[Self]) -> &[T] { + Self::cast_slice_to_core(slice).as_flattened() + } + + /// Obtain a mutable flattened slice from a mutable slice of array chunks. + #[inline] + pub fn slice_as_flattened_mut(slice: &mut [Self]) -> &mut [T] { + Self::cast_slice_to_core_mut(slice).as_flattened_mut() + } } impl Array, U>