Function rs_utils::array::snd_initial [] [src]

pub fn snd_initial<A, B, N, M>(
    from: &GenericArray<(A, B), N>
) -> GenericArray<B, M> where
    B: Clone,
    N: ArrayLength<(A, B)>,
    M: ArrayLength<B> + IsLessOrEqual<N, Output = B1>, 

Create a new array from the second elements of an array of pairs of equal or greater length than the second.

use generic_array::GenericArray;
use typenum::consts::*;
let xs : [(u8, f32); 2]        = [(5, 1.0), (100, -1.0)];
let ys : GenericArray <f32, U1> = snd_initial (&xs.into());
assert_eq!(ys.as_slice(), [1.0]);

A compilation error will result if the length of the input array is shorter than the length of the destination array:

This example deliberately fails to compile
use generic_array::GenericArray;
use typenum::consts::*;
let xs : [(u8, f32); 2]        = [(5, 1.0), (100, -1.0)];
let ys : GenericArray <f32, U3> = snd_initial (&xs.into());