Function rs_utils::array::snd [] [src]

pub fn snd<A, B, N>(from: &GenericArray<(A, B), N>) -> GenericArray<B, N> where
    B: Clone,
    N: ArrayLength<(A, B)> + ArrayLength<B>, 

Create a new array from the second elements of an array of pairs of the same length as the second array.

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

A compilation error will result if the lengths of the arrays do not match:

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, U1> = snd (&xs.into());