The actual mapError function.
A new Expected object containing the result.
{ assert(expected(42).mapError!(e => e).value == 42); assert(unexpected("foo").mapError!(e => 42).error == 42); assert(unexpected("foo").mapError!(e => new Exception(e)).error.msg == "foo"); } // remap hook { static struct Hook {} auto res = expected(42).mapError!(e => e, Hook); assert(res == 42); static assert(is(typeof(res) == Expected!(int, string, Hook))); auto res2 = unexpected!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.