Peekable iterator that allows to peek the next N elements without consuming them.

Related tags

Utilities peekaboo
Overview

peekaboo

docs - crates.io

Peekable iterator that allows to peek the next N elements without consuming them.

It's no_std compatible by default. It also doesn't perform any allocations.

Examples

Basic usage:

let xs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
// create an iterator that allows us to peek at the next 4 element
let mut iter = xs.iter().peekable_n::<4>();

// peek() lets us see into the future
assert_eq!(iter.peek::<1>(), Some(&&1));
assert_eq!(iter.peek::<3>(), Some(&&3));

// the iterator will not advance until we call `next`
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));

Use

Run cargo add peekaboo (if using a Rust version over 1.62), or manually add

peekaboo = "0.2.1"

to your Cargo.toml

You might also like...
1️⃣ el lisp number uno - one lisp to rule them all 🏆

luno el lisp number uno luno is the one lisp to rule them all. Still experimental, do not use it in production yet. goals embeddable small size simple

"Philips Ambilight for desktops". A tool to generate color palettes from your desktop wallpaper and send them to Home Assistant.

Desktop Dye DesktopDye is an open source project written in Rust that allows users to have their lights paired with Home Assistant adjust to the most

One copy of Electron to rule them all.

chroma One copy of Electron to rule them all. chroma keeps a central, up-to-date version of Electron, and makes all your installed Electron apps use i

A crate providing a tracing-subscriber layer for formatting events so Datadog can parse them

Datadog Formatting Layer A crate providing a tracing-subscriber layer for formatting events so Datadog can parse them. Features Provides a layer for t

bevy_blender is a Bevy library that allows you to use assets created in Blender directly from the .blend file
bevy_blender is a Bevy library that allows you to use assets created in Blender directly from the .blend file

bevy_blender bevy_blender is a Bevy library that allows you to use assets created in Blender directly from the .blend file.

This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to the arrow format.

Arrow2-derive - derive for Arrow2 This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to th

Postgres proxy which allows tools that don't natively supports IAM auth to connect to AWS RDS instances.

rds-iamauth-proxy rds-proxy lets you make use of IAM-based authentication to AWS RDS instances from tools that don't natively support that method of a

This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files.

FTZZ File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files. Installation $ cargo +nightly install

Owner
annie
she/it
annie
Rust crate for making Read streams peekable.

peekread This crate allows you to take an arbitrary Read stream and 'peek ahead' into the stream without consuming the original stream. This is done t

Orson Peters 21 Oct 29, 2022
Create virtual serial ports, connect them to physical serial ports, and create routes between them all.

Virtual Serial Port Router (vsp-router) Create virtual serial ports, connect them to physical serial ports, and create routes between them all. vsp-ro

Rob Donnelly 3 Nov 24, 2022
A lending iterator trait based on generic associated types and higher-rank trait bounds

A lending iterator trait based on higher-rank trait bounds (HRTBs) A lending iterator is an iterator which lends mutable borrows to the items it retur

Sebastiano Vigna 6 Oct 23, 2023
The lambda-chaos-extension allows you to inject faults into Lambda functions without modifying the function code.

Chaos Extension - Seamless, Universal & Lightning-Fast The lambda-chaos-extension allows you to inject faults into Lambda functions without modifying

AWS CLI Tools 5 Aug 2, 2023
A formal, politely verbose programming language for building next-gen reliable applications

vfpl Pronounced "Veepl", the f is silent A politely verbose programming language for building next-gen reliable applications Syntax please initialize

VFPL 4 Jun 27, 2022
Automatically transform your Next.js Pages to use SuperJSON with SWC

?? NEXT SUPERJSON PLUGIN export default function Page({ date }) { return ( <div> Today is {date.toDateString()} </div> ) } // You c

⚡️Blitz 92 Jan 4, 2023
🦸‍♂️ Recast migrates your old extensions to AndroidX, making them compatible with the latest version of Kodular.

Recast Recast helps make your old extensions compatible with Kodular Creator version 1.5.0 or above. Prerequisites To use Recast, you need to have Jav

Shreyash Saitwal 13 Dec 28, 2022
A tool to subscribe to Twitch channels and store them efficiently on disk

twitch-messages A tool to subscribe to Twitch channels and store them efficiently on disk Build the Tools You can start by building the binaries that

Clément Renault 1 Oct 31, 2021
💫 Small microservice to handle state changes of Kubernetes pods and post them to Instatus or Statuspages

?? Kanata Small microservice to handle state changes of Kubernetes pods and post to Instatus ?? Why? I don't really want to implement and repeat code

Noel ʕ •ᴥ•ʔ 4 Mar 4, 2022
Generate enum from a trait, with converters between them

Derive macro for Rust that turns traits into enums, providing tools for calling funtions over channels

Vitaly Shukela 16 Nov 3, 2022