[][src]Function dasp::slice::to_boxed_frame_slice

pub fn to_boxed_frame_slice<T, F>(slice: T) -> Option<Box<[F]>> where
    F: Frame,
    T: ToBoxedFrameSlice<F>, 

Converts the given boxed slice into a boxed slice of Frames.

Returns None if the number of channels in a single frame F is not a multiple of the number of samples in the given slice.

This is a convenience function that wraps the ToBoxedFrameSlice trait.

Examples

fn main() {
    let foo = vec![0.0, 0.5, 0.0, -0.5].into_boxed_slice();
    let bar: Box<[[f32; 2]]> = dasp_slice::to_boxed_frame_slice(foo).unwrap();
    assert_eq!(bar.into_vec(), vec![[0.0, 0.5], [0.0, -0.5]]);

    let foo = vec![0.0, 0.5, 0.0].into_boxed_slice();
    let bar = dasp_slice::to_boxed_frame_slice(foo);
    assert_eq!(bar, None::<Box<[[f32; 2]]>>);
}

Required Features

  • When using dasp_slice, this item requires the boxed feature to be enabled.
  • When using dasp, this item requires the slice-boxed feature to be enabled.