Skip to content

Commit

Permalink
Implement std::error::Error for AccumulatorError (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
weikengchen authored Jun 26, 2023
1 parent 54cee96 commit b4d4bb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions accumulators/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use noah_algebra::error;
use noah_algebra::prelude::AlgebraError;

pub(crate) type Result<T> = core::result::Result<T, AccumulatorError>;
Expand Down Expand Up @@ -32,3 +33,10 @@ impl From<Box<dyn ruc::err::RucError>> for AccumulatorError {
AccumulatorError::Ruc(format!("{}", e))
}
}

impl error::Error for AccumulatorError {
#[cfg(feature = "std")]
fn description(&self) -> &str {
Box::leak(format!("{}", self).into_boxed_str())
}
}
4 changes: 2 additions & 2 deletions algebra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pub mod rand_helper;

#[doc(hidden)]
pub use ark_std::{
borrow, cfg_into_iter, cmp, collections, end_timer, fmt, hash, io, iter, marker, ops, rand,
result, start_timer, str, One, UniformRand, Zero,
borrow, cfg_into_iter, cmp, collections, end_timer, error, fmt, hash, io, iter, marker, ops,
rand, result, start_timer, str, One, UniformRand, Zero,
};

/// Implement serialization and deserialization
Expand Down

0 comments on commit b4d4bb1

Please sign in to comment.