pub fn filled_by_row_major<F>(mut generator: F, num_rows: usize, num_columns: usize) -> Self
    where
        F: FnMut() -> T,
    {
        let total_len = num_rows * num_columns;
        let array = (0..total_len).map(|_| generator()).collect();
        Array2D {
            array,
            num_rows,
            num_columns,
        }
    }
/// Creates a new [`Array2D`] with the specified number of rows and columns
/// and fills each element with the result of calling the given
/// function. The function is called once for every location going in
/// row major order.
///
/// # Examples
///
/// ```
/// # use array2d::{Array2D, Error};
/// let mut counter = 1;
/// let increment = || {
///     let tmp = counter;
///     counter += 1;
///     tmp
/// };
/// let array = Array2D::filled_by_row_major(increment, 2, 3);
/// assert_eq!(array.as_rows(), vec![vec![1, 2, 3], vec![4, 5, 6]]);
/// ```
///
/// [`Array2D`]: struct.Array2D.html
Creates a new [`Array2D`] with the specified number of rows and columns
and fills each element with the result of calling the given
function. The function is called once for every location going in
row major order.
Creates a new [ ` Array2D ` ] with the specified number of rows and columns and fills each element with the result of calling the given function . The function is called once for every location going in row major order .
pub fn filled_by_row_major<F>(mut generator: F, num_rows: usize, num_columns: usize) -> Self
    where
        F: FnMut() -> T,
    {
        let total_len = num_rows * num_columns;
        let array = (0..total_len).map(|_| generator()).collect();
        Array2D {
            array,
            num_rows,
            num_columns,
        }
    }
pub fn filled_by_row_major < F > ( mut generator : F , num_rows : usize , num_columns : usize ) -> Self where F : FnMut ( ) -> T , { let total_len = num_rows * num_columns ; let array = ( 0 .. total_len ) . map ( | _ | generator ( ) ) . collect ( ) ; Array2D { array , num_rows , num_columns , } }
Creates a new [`Array2D`] with the specified number of rows and columns
and fills each element with the result of calling the given
function.
Creates a new [ ` Array2D ` ] with the specified number of rows and columns and fills each element with the result of calling the given function .
generator
F
num_rows
usize
num_columns
usize
generator
F
num_rows
usize
num_columns
usize
examples
None
use array2d::{array2d, error};
None