# Trait generic_array::ArrayLength

source · ```
pub unsafe trait ArrayLength: Unsigned + 'static {
type ArrayType<T>: Sealed;
}
```

## Expand description

Trait used to define the number of elements in a `GenericArray`

.

`ArrayLength`

is a superset of `typenum::Unsigned`

.

Consider `N: ArrayLength`

to be equivalent to `const N: usize`

```
fn foo<N: ArrayLength>(arr: GenericArray<i32, N>) -> i32 {
arr.iter().sum()
}
```

is equivalent to:

```
fn foo<const N: usize>(arr: [i32; N]) -> i32 {
arr.iter().sum()
}
```

## §Safety

This trait is effectively sealed due to only being allowed on `Unsigned`

types,
and therefore cannot be implemented in user code.

## Required Associated Types§

source#### type ArrayType<T>: Sealed

#### type ArrayType<T>: Sealed

Associated type representing the underlying contiguous memory that constitutes an array with the given number of elements.

This is an implementation detail, but is required to be public in cases where certain attributes
of the inner type of `GenericArray`

cannot be proven, such as `Copy`

bounds.

`Copy`

example:

```
struct MyType<N: ArrayLength> {
data: GenericArray<f32, N>,
}
impl<N: ArrayLength> Clone for MyType<N> where N::ArrayType<f32>: Copy {
fn clone(&self) -> Self { MyType { ..*self } }
}
impl<N: ArrayLength> Copy for MyType<N> where N::ArrayType<f32>: Copy {}
```

Alternatively, using the entire `GenericArray<f32, N>`

type as the bounds works:

ⓘ

`where GenericArray<f32, N>: Copy`

## Object Safety§

This trait is

**not**object safe.