Rust, Design Patterns, Matrix Factorization, Numerical Methods, Software Engineering.
self.cols.ok_or(MatrixDefinitionError::UndefinedCols)?; if data.len() != rows * cols { Err(MatrixDefinitionError::DataLengthDoesNotMatchRowsTimesCols) } else { Ok(Matrix { rows, cols, data }) } } } Note that the builder returns an error is one of the field is None. (See the full implementation on