From 037226bb1f1a010d5bc3d1c63073e435e1ee80fe Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Mon, 9 May 2022 10:02:26 +0200 Subject: [PATCH] Use ? instead of unwrap() in examples --- nalgebra-sparse/src/io/matrix_market.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nalgebra-sparse/src/io/matrix_market.rs b/nalgebra-sparse/src/io/matrix_market.rs index 489449a3..36ca5ca4 100644 --- a/nalgebra-sparse/src/io/matrix_market.rs +++ b/nalgebra-sparse/src/io/matrix_market.rs @@ -1439,6 +1439,7 @@ fn next_dense_coordinate( /// -------- /// ``` /// # use nalgebra_sparse::CooMatrix; +/// # fn main() -> Result<(), Box> { /// use nalgebra_sparse::io::{save_to_matrix_market_str}; /// let expected_str = r#"%%matrixmarket matrix coordinate integer general /// % matrixmarket file generated by nalgebra-sparse. @@ -1449,9 +1450,10 @@ fn next_dense_coordinate( /// let row_indices = vec![0,1]; /// let col_indices = vec![0,2]; /// let values = vec![10,5]; -/// let matrix = CooMatrix::try_from_triplets(5,4,row_indices,col_indices,values).unwrap(); +/// let matrix = CooMatrix::try_from_triplets(5,4,row_indices,col_indices,values)?; /// let generated_matrixmarket_str = save_to_matrix_market_str(&matrix); /// assert_eq!(expected_str,generated_matrixmarket_str); +/// # Ok(()) } /// ``` pub fn save_to_matrix_market_str( sparse_matrix: &S, @@ -1482,6 +1484,7 @@ where /// Examples /// -------- /// ```no_run +/// # fn main() -> Result<(), Box> { /// use nalgebra_sparse::io::{save_to_matrix_market_file,load_coo_from_matrix_market_str}; /// let str = r#" /// %%matrixmarket matrix coordinate integer general @@ -1489,8 +1492,9 @@ where /// 1 1 10 /// 2 3 5 /// "#; -/// let matrix = load_coo_from_matrix_market_str::(&str).unwrap(); -/// save_to_matrix_market_file(&matrix,"path/to/matrix.mtx").unwrap(); +/// let matrix = load_coo_from_matrix_market_str::(&str)?; +/// save_to_matrix_market_file(&matrix,"path/to/matrix.mtx")?; +/// # Ok(()) } /// ``` pub fn save_to_matrix_market_file( sparse_matrix: &S,