Function sample::slice::to_frame_slice_mut [] [src]

pub fn to_frame_slice_mut<'a, T, F>(slice: T) -> Option<&'a mut [F]> where F: Frame, T: ToFrameSliceMut<'a, F>

Converts the given mutable slice into a mutable 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 ToFrameSliceMut trait.

Examples

extern crate sample;

fn main() {
    let foo = &mut [0.0, 0.5, 0.0, -0.5][..];
    let bar = sample::slice::to_frame_slice_mut(foo);
    assert_eq!(bar, Some(&mut [[0.0, 0.5], [0.0, -0.5]][..]));

    let foo = &mut [0.0, 0.5, 0.0][..];
    let bar = sample::slice::to_frame_slice_mut(foo);
    assert_eq!(bar, None::<&mut [[f32; 2]]>);
}