Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/hybrid-array.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --no-default-features --target ${{ matrix.target }}
- run: cargo build --no-default-features --target ${{ matrix.target }} --features alloc
- run: cargo build --no-default-features --target ${{ matrix.target }} --features bytemuck
- run: cargo build --no-default-features --target ${{ matrix.target }} --features extra-sizes
- run: cargo build --no-default-features --target ${{ matrix.target }} --features serde
Expand Down Expand Up @@ -110,6 +111,7 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
- run: cargo test
- run: cargo test --features alloc
- run: cargo test --features bytemuck
- run: cargo test --features extra-sizes
- run: cargo test --features serde
Expand Down
46 changes: 46 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,52 @@ where
}
}

#[cfg(feature = "alloc")]
impl<T, U> From<Array<T, U>> for alloc::boxed::Box<[T]>
where
U: ArraySize,
{
#[inline]
fn from(array: Array<T, U>) -> alloc::boxed::Box<[T]> {
array.into_iter().collect()
}
}

#[cfg(feature = "alloc")]
impl<T, U> From<&Array<T, U>> for alloc::boxed::Box<[T]>
where
T: Clone,
U: ArraySize,
{
#[inline]
fn from(array: &Array<T, U>) -> alloc::boxed::Box<[T]> {
array.as_slice().into()
}
}

#[cfg(feature = "alloc")]
impl<T, U> From<Array<T, U>> for alloc::vec::Vec<T>
where
U: ArraySize,
{
#[inline]
fn from(array: Array<T, U>) -> alloc::vec::Vec<T> {
array.into_iter().collect()
}
}

#[cfg(feature = "alloc")]
impl<T, U> From<&Array<T, U>> for alloc::vec::Vec<T>
where
T: Clone,
U: ArraySize,
{
#[inline]
fn from(array: &Array<T, U>) -> alloc::vec::Vec<T> {
array.as_slice().into()
}
}

impl<T, U> Hash for Array<T, U>
where
T: Hash,
Expand Down