File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 15
15
//! }
16
16
//! ```
17
17
//!
18
+ //! However, **make sure to only use the above form with a mutable reference to an existing iterator**,
19
+ //! not with an expression that creates an iterator.
20
+ //! For example, the following code will loop forever over the first element of the array:
21
+ //!
22
+ //! ```no_run
23
+ //! use streaming_iterator::{convert, StreamingIterator};
24
+ //! let array = [0, 1, 2, 3];
25
+ //!
26
+ //! while let Some(item) = convert(array.iter()).next() {
27
+ //! // This is an infinite loop!
28
+ //! }
29
+ //! ```
30
+ //!
18
31
//! While the standard `Iterator` trait's functionality is based off of the `next` method,
19
32
//! `StreamingIterator`'s functionality is based off of a pair of methods: `advance` and `get`. This
20
33
//! essentially splits the logic of `next` in half (in fact, `StreamingIterator`'s `next` method
You can’t perform that action at this time.
0 commit comments