Skip to content

Commit a077d50

Browse files
committed
Improve docs for Stream
1 parent fd9de33 commit a077d50

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/elixir/lib/stream.ex

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,21 @@ defmodule Stream do
9090
This module also provides many convenience functions for creating streams,
9191
like `Stream.cycle/1`, `Stream.unfold/2`, `Stream.resource/3` and more.
9292
93-
Note the functions in this module are guaranteed to return enumerables.
94-
Since enumerables can have different shapes (structs, anonymous functions,
95-
and so on), the functions in this module may return any of those shapes
96-
and this may change at any time. For example, a function that today
97-
returns an anonymous function may return a struct in future releases.
93+
> #### Do not check for `Stream` structs
94+
>
95+
> While some functions in this module may return the `Stream` struct,
96+
> you must never explicitly check for the `Stream` struct, as streams
97+
> may come in several shapes, such as `IO.Stream`, `File.Stream`, or
98+
> even `Range`s.
99+
>
100+
> The functions in this module only guarantee to return enumerables
101+
> and their implementation (structs, anonymous functions, etc) may
102+
> change at any time. For example, a function that returns an anonymous
103+
> function today may return a struct in future releases.
104+
>
105+
> Instead of checking for a particular type, you must instead write
106+
> assertive code that assumes you have an enumerable, using the functions
107+
> in the `Enume` or `Stream` module accordingly.
98108
"""
99109

100110
@doc false

0 commit comments

Comments
 (0)