The type signature of Result::map_or_else:
pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U where
F: FnOnce(T) -> U,
D: FnOnce(E) -> U,
Note how default is the function that gets applied to the Err variant. Then, the docstring (emphasis mine):
Maps a Result<T, E> to U by applying a fallback function to a contained Err value, or a default function to a contained Ok value.
I think this is a very unfortunate choice of words and should be changed.
The type signature of
Result::map_or_else:Note how
defaultis the function that gets applied to theErrvariant. Then, the docstring (emphasis mine):I think this is a very unfortunate choice of words and should be changed.