#[on_error]Expand description
Attribute macro that runs cleanup code when a method returns an error.
§Usage
ⓘ
#[on_error(self.cleanup())]
pub fn do_something(&mut self) -> Result<(), Error> {
self.inner_work()?;
Ok(())
}For methods returning Result<&mut Self, E>, the macro properly handles
the borrow by discarding the returned reference and returning a fresh Ok(self):
ⓘ
#[on_error(self.poison_and_cleanup())]
pub fn begin_some(&mut self) -> Result<&mut Self, ReflectError> {
self.require_active()?;
// ... implementation
Ok(self)
}