consume method

Optional<O> consume()

Implementation

Optional<O> consume() {
  return cases.entries.fold(empty<O>(), (carry, entry) {
    return carry is Empty<O> && entry.key(value) // @formatter:off
        ? present(entry).map((match) => match.value(value))
        : carry; // @formatter:on
  });
}