#1882·nom

Self documenting code is unnecessarily cryptic

Author: gdennieCreated May 21, 2026Updated May 22, 2026

The following does not easily suggest the types in its Result.

fn map_res<G, O2, E2>(self, g: G) -> MapRes<Self, G>
where
    G: FnMut(Self::Output) -> Result<O2, E2>,
    Self::Error: FromExternalError<Input, E2>,
    Self: Sized,

Applies a function returning a Result over the result of a parser.

...perhaps something as follows:

fn map_res<G, Output, Error>(self, g: G) -> MapRes<Self, G>
where
    G: FnMut(Self::Output) -> Result<Output, Error>,
    Self::Error: FromExternalError<Input, Error>,
    Self: Sized,

Applies a function returning a Result over the result of a parser.

or even clearer...

fn map_res<G, NewOutput, NewError>(self, g: G) -> MapRes<Self, G>
where
    G: FnMut(Self::Output) -> Result<NewOutput, NewError>,
    Self::Error: FromExternalError<Input, NewError>,
    Self: Sized,

Applies a function returning a Result over the result of a parser.

What is clear can become hard to see after long familiarity. I only belatedly appreciated the intended numbering sequence: O1, O2, etc. However, it is a mental tax I'd prefer to spend elsewhere, especially when such brevity is not necessary. Ease of use is also technological sophistication.