/// Efficiently creates a matrix with the given rows.
///
/// Returns `None` if any of the row lengths are too short or not enough
/// rows are provided, or if either of `num_rows` or `num_cols` represents
/// `0`.
Efficiently creates a matrix with the given rows.
Efficiently creates a matrix with the given rows .
pub fn from_rows<Rows, Row>(num_rows: N, num_cols: M, rows: Rows) -> Option<Self>
        where Rows: IntoIterator<Item = Row>,
              Row: IntoIterator<Item = T>
    {
        if num_rows.as_nat() == 0 || num_cols.as_nat() == 0 {
            return None;
        }
        let target_size = num_rows.as_nat() * num_cols.as_nat();
        let res = unsafe { Self::from_rows_unsafe(num_rows, num_cols, rows) };
        // check that we have actually filled the matrix
        if res.data.len() != target_size {
            return None;
        }
        Some(res)
    }
pub fn from_rows < Rows , Row > ( num_rows : N , num_cols : M , rows : Rows ) -> Option < Self > where Rows : IntoIterator < Item = Row > , Row : IntoIterator < Item = T > { if num_rows . as_nat ( ) == 0 || num_cols . as_nat ( ) == 0 { return None ; } let target_size = num_rows . as_nat ( ) * num_cols . as_nat ( ) ; let res = unsafe { Self :: from_rows_unsafe ( num_rows , num_cols , rows ) } ; // check that we have actually filled the matrix if res . data . len ( ) != target_size { return None ; } Some ( res ) }
Efficiently creates a matrix with the given rows.
Efficiently creates a matrix with the given rows .
num_rows
N
num_cols
M
rows
Rows