diff --git a/nalgebra-sparse/src/io/matrix_market.rs b/nalgebra-sparse/src/io/matrix_market.rs index 518675cd..dd823bc9 100644 --- a/nalgebra-sparse/src/io/matrix_market.rs +++ b/nalgebra-sparse/src/io/matrix_market.rs @@ -298,13 +298,14 @@ impl fmt::Display for MatrixMarketError { impl std::error::Error for MatrixMarketError {} -impl From> - for MatrixMarketError -{ - fn from(err: pest::error::Error) -> Self { +impl MatrixMarketError { + fn from_pest_error(error: pest::error::Error) -> Self + where + T: fmt::Debug + std::hash::Hash + std::marker::Copy + Ord + { Self::from_kind_and_message( MatrixMarketErrorKind::ParsingError, - format!("Can't parse the data.\n Error: {}", err), + format!("Can't parse the data.\n Error: {}", error), ) } } @@ -756,7 +757,9 @@ where T: MatrixMarketScalar, { // unwrap() in this function are guaranteed by parsing the data - let file = MatrixMarketParser::parse(Rule::Document, data)?.next().unwrap(); + let file = MatrixMarketParser::parse(Rule::Document, data) + .map_err(MatrixMarketError::from_pest_error)? + .next().unwrap(); let mut rows: Vec = Vec::new(); let mut cols: Vec = Vec::new();