code: public static <T> Single<T> toSingle(Publisher<T> publisher) {
          if (publisher == null) {
              throw new NullPointerException("publisher");
          }
          return Single.create(new PublisherAsSingle<T>(publisher));
      }
docs: Converts a Publisher into a Single which emits onSuccess if the
  Publisher signals an onNext+onComplete; or onError if the publisher signals an
  onError, the source Publisher is empty (NoSuchElementException) or the
  source Publisher signals more than one onNext (IndexOutOfBoundsException).
  @param <T> the value type
  @param publisher the Publisher instance to convert
  @return the Single instance
  @since 1.1
  @throws NullPointerException if publisher is null