exactlyOne<T> function

T exactlyOne<T>(
  1. List<T> items,
  2. String what
)

Throw unless exactly one what receipt was decoded; return it. The singular decoders use this; the plural forms return all matches (an integrator batching N actions in one PTB gets N receipts).

Implementation

T exactlyOne<T>(List<T> items, String what) {
  if (items.length != 1) {
    throw PredictInputError(
        'expected exactly one $what event, found ${items.length}');
  }
  return items[0];
}