Example #1
0
 def on_completed():
     nonlocal last_value
     if has_value:
         future.set_result(last_value)
     else:
         future.set_exception(SequenceContainsNoElementsError())
     last_value = None
 def on_completed():
     if not seen_value[0] and not has_default:
         observer.on_error(SequenceContainsNoElementsError())
     else:
         observer.on_next(value[0])
         observer.on_completed()
Example #3
0
def first_only(x):
    if not len(x):
        raise SequenceContainsNoElementsError()

    return x[0]
Example #4
0
def first_only(x: Sequence) -> Any:
    if not x:
        raise SequenceContainsNoElementsError()

    return x[0]