Trait generic_array::IntoArrayLength
source · pub trait IntoArrayLength {
type ArrayLength: ArrayLength;
}
Expand description
Implemented for types which can have an associated ArrayLength
,
such as Const<N>
for use with const-generics.
use generic_array::{GenericArray, IntoArrayLength, ConstArrayLength, typenum::Const};
fn some_array_interopt<const N: usize>(value: [u32; N]) -> GenericArray<u32, ConstArrayLength<N>>
where
Const<N>: IntoArrayLength,
{
let ga = GenericArray::from(value);
// do stuff
ga
}
This is mostly to simplify the where
bounds, equivalent to:
use generic_array::{GenericArray, ArrayLength, typenum::{Const, U, ToUInt}};
fn some_array_interopt<const N: usize>(value: [u32; N]) -> GenericArray<u32, U<N>>
where
Const<N>: ToUInt,
U<N>: ArrayLength,
{
let ga = GenericArray::from(value);
// do stuff
ga
}
Required Associated Types§
sourcetype ArrayLength: ArrayLength
type ArrayLength: ArrayLength
The associated ArrayLength