# precog_iter [![Crates.io](https://img.shields.io/crates/v/precog_iter.svg)](https://crates.io/crates/precog_iter) [![Docs.rs](https://docs.rs/precog_iter/badge.svg)](https://docs.rs/precog_iter/) [![License: MIT/Apache-2.0](https://img.shields.io/crates/l/precog_iter.svg)](#license) [![Build status](https://travis-ci.com/ChrisDenton/precog_iter.svg?branch=master)](https://travis-ci.org/ChrisDenton/precog_iter) An iterator adapter that returns the equivalent of `(iter.next(), iter.peek())`. ## Installation Add a dependency to your `Cargo.toml`. ```toml [dependencies] precog_iter = "0.5" ``` Then use the trait in your `main.rs` or `lib.rs` file. ```rust use precog_iter::Precognition; ``` ## Usage ```rust use precog_iter::Precognition; let mut iter = "ABAC".chars() .precog() .filter_map(|(codepoint, next)| { // Remove codepoint if followed by 'C'. match next { Some(n) if n == 'C' => { None } _ => Some(codepoint) } }); assert_eq!(iter.next(), Some('A')); assert_eq!(iter.next(), Some('B')); // The second 'A' has been filtered assert_eq!(iter.next(), Some('C')); assert_eq!(iter.next(), None); ``` ## License Licensed under either of * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. ## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.