<s> from rx import Observable , AnonymousObservable <EOL> from rx . internal import extensionmethod <EOL> def _to_set ( source , set_type ) : <EOL> def subscribe ( observer ) : <EOL> s = set_type ( ) <EOL> def on_completed ( ) : <EOL> observer . on_next ( s ) <EOL> observer . on_completed ( ) <EOL> return source . subscribe ( s . add , observer . on_error , on_completed ) <EOL> return AnonymousObservable ( subscribe ) <EOL> @ extensionmethod ( Observable ) <EOL> def to_set ( self ) : <EOL> """<STR_LIT>""" <EOL> return _to_set ( self , set ) </s>
