Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Sep 13, 2023
1 parent 9b12a1a commit 7e53053
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -79,6 +79,7 @@ features = [
"serde", # Serialize/Deserialize implementation
"zeroize", # Zeroize implementation for setting array elements to zero
"const-default", # Compile-time const default value support via trait
"alloc" # Enables From/TryFrom implementations between GenericArray and Vec<T>/Box<[T]>
"alloc", # Enables From/TryFrom implementations between GenericArray and Vec<T>/Box<[T]>
"faster-hex" # Enables internal use of the `faster-hex` crate for faster hex encoding via SIMD
]
```
28 changes: 15 additions & 13 deletions src/arr.rs
Expand Up @@ -68,20 +68,22 @@ macro_rules! box_arr {
});
}

use crate::{ArrayLength, GenericArray, IntoArrayLength};

#[cfg(feature = "alloc")]
impl<T, N: ArrayLength> GenericArray<T, N> {
#[doc(hidden)]
#[inline(always)]
pub fn __from_vec_helper<const U: usize>(
_empty: [(); U],
vec: alloc::vec::Vec<T>,
) -> alloc::boxed::Box<GenericArray<T, N>>
where
typenum::Const<U>: IntoArrayLength<ArrayLength = N>,
{
unsafe { GenericArray::try_from_vec(vec).unwrap_unchecked() }
mod alloc_helper {
use crate::{ArrayLength, GenericArray, IntoArrayLength};

impl<T, N: ArrayLength> GenericArray<T, N> {
#[doc(hidden)]
#[inline(always)]
pub fn __from_vec_helper<const U: usize>(
_empty: [(); U],
vec: alloc::vec::Vec<T>,
) -> alloc::boxed::Box<GenericArray<T, N>>
where
typenum::Const<U>: IntoArrayLength<ArrayLength = N>,
{
unsafe { GenericArray::try_from_vec(vec).unwrap_unchecked() }
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Expand Up @@ -78,7 +78,8 @@
//! "serde", # Serialize/Deserialize implementation
//! "zeroize", # Zeroize implementation for setting array elements to zero
//! "const-default", # Compile-time const default value support via trait
//! "alloc" # Enables From/TryFrom implementations between GenericArray and Vec<T>/Box<[T]>
//! "alloc". # Enables From/TryFrom implementations between GenericArray and Vec<T>/Box<[T]>
//! "faster-hex" # Enables internal use of the `faster-hex` crate for faster hex encoding via SIMD
//! ]
//! ```

Expand Down

0 comments on commit 7e53053

Please sign in to comment.