mapSync method

  1. @override
  2. @visibleForTesting
Sync<T> mapSync(
  1. @noFutures Sync<T> noFutures(
    1. Sync<T> sync
    )
)
override

Transforms the inner Sync instance if this is a Sync.

Provided for pair-axis symmetry with Result.mapOk/Result.mapErr — real code almost always wants resultMap, fold, or foldResult instead, since those operate on the inner Result where the meaningful payload lives.

Implementation

@override
@visibleForTesting
@pragma('vm:prefer-inline')
Sync<T> mapSync(@noFutures Sync<T> Function(Sync<T> sync) noFutures) {
  try {
    return noFutures(this);
  } on Err catch (err) {
    return Sync.err(err.transfErr<T>());
  } catch (error, stackTrace) {
    return Sync.err(Err<T>(error, stackTrace: stackTrace));
  }
}