status-im / nim-stew

stew is collection of utilities, std library extensions and budding libraries that are frequently used at Status, but are too small to deserve their own git repository.
133 stars 18 forks source link

results: add `mapConvertErr`, `mapCastErr` #178

Closed arnetheduck closed 1 year ago

arnetheduck commented 1 year ago

We already have mapConvert and mapCast - this completes the API with corresponding Err versions similar to mapErr.

The Convert / Cast operators are of somewhat dubious value - ie they exist as "efficiency" shortcuts for map for the case that the mapping should be done as a simple cast / conversion - an alternative would be to deprecate these features and aim for some other, more generic version that involves a type conversion library such as https://github.com/status-im/nim-stew/pull/34, though this inherently, and perhaps rightly, would be limited to "error-free" conversions.

Regardless, these helpers provide balance to the existing API.