MCPcopy Create free account
hub / github.com/hashintel/hash / finish_with

Method finish_with

libs/error-stack/src/sink.rs:303–306  ·  view source on GitHub ↗

Finishes the sink and returns a [`Result`] with a custom success value. Similar to [`finish`], but allows specifying a function to generate the success value. # Examples ``` # use error_stack::ReportSink; # use std::io; let mut sink = ReportSink::new(); # // needed for type inference # sink.capture(io::Error::new(io::ErrorKind::Other, "I/O error")); // ... add errors ... let result = sink.finis

(mut self, ok: impl FnOnce() -> T)

Source from the content-addressed store, hash-verified

301 ///
302 /// [`finish`]: ReportSink::finish
303 pub fn finish_with<T>(mut self, ok: impl FnOnce() -> T) -> Result<T, Report<[C]>> {
304 self.bomb.defuse();
305 self.report.map_or_else(|| Ok(ok()), Err)
306 }
307
308 /// Finishes the sink and returns a [`Result`] with a default success value.
309 ///

Callers 3

newMethod · 0.45
finish_withFunction · 0.45
finish_with_okFunction · 0.45

Calls 3

OkInterface · 0.85
okFunction · 0.85
defuseMethod · 0.80

Tested by 2

finish_withFunction · 0.36
finish_with_okFunction · 0.36