peepable 0.1.1

Peepable is a Peekable that allows peeping into immutable references
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented3 out of 3 items with examples
  • Size
  • Source code size: 9.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.11 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • brendanashworth/peepable
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • brendanashworth

peepable

Crates.io Build Status docs.rs

peepable is a Rust look-alike for Peekable. It behaves slightly different as it eagerly loads the next value in the Iterator. This allows .peep() to be called on an immutable reference, saving you from the borrow checker.

Example

use std::iter::Iterator;
use peepable::Peepable;

let mut iter = vec![1, 2, 3].into_iter();

// Note, this is not "mut peeper"!
let peeper = Peepable::new(iter);

assert_eq!(peeper.peep(), Some(&1));

// When mutable, we can use it as a normal iterator.
let mut peeper = peeper;

assert_eq!(peeper.next(), Some(1));

assert_eq!(peeper.peep(), Some(&2));
assert_eq!(peeper.next(), Some(2));

assert_eq!(peeper.next(), Some(3));

assert_eq!(peeper.peep(), None);
assert_eq!(peeper.next(), None);

License

peepable is licensed under the MIT license.