Use ? instead of unwrap() in examples
This commit is contained in:
parent
59421896ce
commit
037226bb1f
|
@ -1439,6 +1439,7 @@ fn next_dense_coordinate(
|
||||||
/// --------
|
/// --------
|
||||||
/// ```
|
/// ```
|
||||||
/// # use nalgebra_sparse::CooMatrix;
|
/// # use nalgebra_sparse::CooMatrix;
|
||||||
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// use nalgebra_sparse::io::{save_to_matrix_market_str};
|
/// use nalgebra_sparse::io::{save_to_matrix_market_str};
|
||||||
/// let expected_str = r#"%%matrixmarket matrix coordinate integer general
|
/// let expected_str = r#"%%matrixmarket matrix coordinate integer general
|
||||||
/// % matrixmarket file generated by nalgebra-sparse.
|
/// % matrixmarket file generated by nalgebra-sparse.
|
||||||
|
@ -1449,9 +1450,10 @@ fn next_dense_coordinate(
|
||||||
/// let row_indices = vec![0,1];
|
/// let row_indices = vec![0,1];
|
||||||
/// let col_indices = vec![0,2];
|
/// let col_indices = vec![0,2];
|
||||||
/// let values = vec![10,5];
|
/// 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);
|
/// let generated_matrixmarket_str = save_to_matrix_market_str(&matrix);
|
||||||
/// assert_eq!(expected_str,generated_matrixmarket_str);
|
/// assert_eq!(expected_str,generated_matrixmarket_str);
|
||||||
|
/// # Ok(()) }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn save_to_matrix_market_str<T, S>(
|
pub fn save_to_matrix_market_str<T, S>(
|
||||||
sparse_matrix: &S,
|
sparse_matrix: &S,
|
||||||
|
@ -1482,6 +1484,7 @@ where
|
||||||
/// Examples
|
/// Examples
|
||||||
/// --------
|
/// --------
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
|
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
/// use nalgebra_sparse::io::{save_to_matrix_market_file,load_coo_from_matrix_market_str};
|
/// use nalgebra_sparse::io::{save_to_matrix_market_file,load_coo_from_matrix_market_str};
|
||||||
/// let str = r#"
|
/// let str = r#"
|
||||||
/// %%matrixmarket matrix coordinate integer general
|
/// %%matrixmarket matrix coordinate integer general
|
||||||
|
@ -1489,8 +1492,9 @@ where
|
||||||
/// 1 1 10
|
/// 1 1 10
|
||||||
/// 2 3 5
|
/// 2 3 5
|
||||||
/// "#;
|
/// "#;
|
||||||
/// let matrix = load_coo_from_matrix_market_str::<i32>(&str).unwrap();
|
/// let matrix = load_coo_from_matrix_market_str::<i32>(&str)?;
|
||||||
/// save_to_matrix_market_file(&matrix,"path/to/matrix.mtx").unwrap();
|
/// save_to_matrix_market_file(&matrix,"path/to/matrix.mtx")?;
|
||||||
|
/// # Ok(()) }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn save_to_matrix_market_file<T, S, P>(
|
pub fn save_to_matrix_market_file<T, S, P>(
|
||||||
sparse_matrix: &S,
|
sparse_matrix: &S,
|
||||||
|
|
Loading…
Reference in New Issue