The actual mapError function.
A new Expected object containing the result.
{ assert(ok(42).mapError!(e => e).value == 42); assert(err("foo").mapError!(e => 42).error == 42); version (D_Exceptions) assert(err("foo").mapError!(e => new Exception(e)).error.msg == "foo"); } // remap hook { static struct Hook {} auto res = ok(42).mapError!(e => e, Hook); assert(res == 42); static assert(is(typeof(res) == Expected!(int, string, Hook))); auto res2 = err!int("foo").mapError!(e => "bar", Hook); assert(res2.error == "bar"); static assert(is(typeof(res2) == Expected!(int, string, Hook))); }
Applies a function to the expected error in an Expected object.
If no error is present, the original value is passed through unchanged, and the function is not called.