inspectErr method
Calls the provided function with the contained error value if this Result
is Err.
Result<int, String> foo = Err('foo');
String bar = foo
.mapErr((value) => value + 'bar')
.inspectErr((value) => print(value)) // prints: foobar
.unwrapErr();
print(bar); // prints: foobar
See also:
Rust: Result::inspect_err()
Implementation
Result<T, E> inspectErr(void Function(E) fn) {
if (this case Err(value: E v)) {
fn(v);
}
return this;
}