I have a type defined as follows:
pub struct State<T: Clone + Eq> {
pub db: HashSet<T>,
}
And I have a function that looks like the following:
fn check(&self) -> Result<(), Error> {
self.db.iter().for_each(|elem| elem.check());
Ok(())
}
So I want to call check
function for each of the element in HashSet
. I just want to ensure that either all return ()
or there is some Error
thrown. The above throws error as it expect ()
as output of elem.check()
, but it returns Result
. What's the proper way to handle this in Rust?