title: Explain how this lambda can be assigned to an Iterable
body: <p>I came across some clever code to convert an Iterator to a Stream from Karol on <a href="https://stackoverflow.com/questions/23439780/how-to-create-a-java-8-stream-from-an-iterator/23442909#23442909">this post</a>. I have to admit that I don't completely understand how the lambda is allowed to be assigned to the <code>Iterable</code> type in the following code...</p>
  
  <pre><code>static &lt;T&gt; Stream&lt;T&gt; iteratorToFiniteStream(final Iterator&lt;T&gt; iterator) {
      final Iterable&lt;T&gt; iterable = () -&gt; iterator;
      return StreamSupport.stream(iterable.spliterator(), false);
  }
  </code></pre>
  
  <p>I decided to write my own small test to ensure that it compiles and executes, and it does.</p>
  
  <pre><code>public void printsStream_givenIterator()
  {
      Iterator&lt;String&gt; iterator = Arrays.asList("a", "b", "c").iterator();
      final Iterable&lt;String&gt; iterable = () -&gt; iterator;
      StreamSupport.stream(iterable.spliterator(), false).forEach(s -&gt; System.out.println(s));
  }
  
  // prints: abc
  </code></pre>
  
  <p>My understanding is that the lambda <code>() -&gt; iterator</code> is acting as a <a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html" rel="noreferrer">Supplier</a> function.</p>
  
  <p><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html" rel="noreferrer">Iterable</a> isn't a <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/FunctionalInterface.html" rel="noreferrer">FunctionalInterface</a> so how can it be assigned this lambda?</p>