From 42e0c46ad2996af75a30e3cf6ef2d2249892d2ca Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sun, 21 Sep 2025 12:41:36 -0600 Subject: [PATCH 1/2] Add `Array::slice_as_flattened(_mut)` (#142) As requested in RustCrypto/utils#1221 --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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> From 6e38633a3fde9a165043144ba73a34daa7ae0201 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sun, 21 Sep 2025 13:07:55 -0600 Subject: [PATCH 2/2] v0.4.2 (#143) ### Added - `Array::slice_as_flattened(_mut)` (#142) --- CHANGELOG.md | 6 ++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) 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