{"id":16865987,"url":"https://github.com/lukemathwalker/multipeek","last_synced_at":"2025-03-22T07:30:36.807Z","repository":{"id":45806892,"uuid":"482594294","full_name":"LukeMathWalker/multipeek","owner":"LukeMathWalker","description":"An iterator adapter to peek at future elements without advancing the cursor of the underlying iterator.","archived":false,"fork":false,"pushed_at":"2023-04-29T23:49:29.000Z","size":11,"stargazers_count":26,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T03:09:55.223Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LukeMathWalker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-17T17:51:40.000Z","updated_at":"2024-05-03T20:04:10.000Z","dependencies_parsed_at":"2024-10-29T02:45:42.451Z","dependency_job_id":null,"html_url":"https://github.com/LukeMathWalker/multipeek","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"b079dc6375b260ac866db6a3da1bdeec4b2fdbf5"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeMathWalker%2Fmultipeek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeMathWalker%2Fmultipeek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeMathWalker%2Fmultipeek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeMathWalker%2Fmultipeek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeMathWalker","download_url":"https://codeload.github.com/LukeMathWalker/multipeek/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244189791,"owners_count":20412991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T14:49:05.603Z","updated_at":"2025-03-22T07:30:35.698Z","avatar_url":"https://github.com/LukeMathWalker.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003emultipeek\u003c/h1\u003e\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- Crates version --\u003e\n  \u003ca href=\"https://crates.io/crates/multipeek\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/multipeek.svg?style=flat-square\"\n    alt=\"Crates.io version\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Downloads --\u003e\n  \u003ca href=\"https://crates.io/crates/multipeek\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/d/multipeek.svg?style=flat-square\"\n      alt=\"Download\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- docs.rs docs --\u003e\n  \u003ca href=\"https://docs.rs/multipeek\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square\"\n      alt=\"docs.rs docs\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\nAn iterator adapter to peek at future elements without advancing the cursor of the underlying\niterator.\n\nCheck out the [documentation](https://docs.rs/multipeek) for more details.\n\n# Example\n\n```rust\nuse multipeek::multipeek;\n\nlet mut iter = multipeek([1, 2, 3, 4].into_iter());\n\n// Peek at the first element.\nlet first_peek = iter.peek().cloned();\nassert_eq!(first_peek, Some(1));\n\n// Advance the iterator cursor to point at the first element.\nlet first = iter.next();\nassert_eq!(first, first_peek);\n\n// Peek two steps ahead, at the third element.\nlet third_peek = iter.peek_nth(1).cloned();\nassert_eq!(third_peek, Some(3));\n\n// Advance the iterator cursor twice. \n// The iterator cursor will now point to the third element.\niter.next();\nlet third = iter.next();\nassert_eq!(third_peek, third);\n\n// Peeking beyond the end of the iterator returns `None`.\nlet ambitious_peek = iter.peek_nth(5);\nassert!(ambitious_peek.is_none());\n```\n\n# `no_std`\n\n`multipeek` can be used in `no_std` environments. It requires an allocator.\n\n# Alternatives and previous art\n\nRust's standard library provides [`Peekable`](https://doc.rust-lang.org/stable/std/iter/struct.Peekable.html).  \nIt lets you peek at the next element in an iterator, but there is no way to look further ahead.\n\n`itertools`'s provides [`MultiPeek`](https://docs.rs/itertools/latest/itertools/structs/struct.MultiPeek.html).  \nIt lets you peek as far ahead as you want, but [`MultiPeek::peek`](https://docs.rs/itertools/latest/itertools/structs/struct.MultiPeek.html#method.peek)\nis not idempotent: calling `peek` once returns the next element, calling `peek` again\nreturns the second-next element.  \n\n`multipeek`, just like `itertools`, gives you the possibility to peek as far ahead as you want.  \nOur `MultiPeek::peek` implementation is idempotent: `MultiPeek::peek` always returns\nthe next element.  \nYou can peek further ahead using `MultiPeek::peek_nth`, you just need to specify how\nmany steps ahead you want to look at.\n\nOur `MultiPeek` implementation is directly inspired by `itertools`' implementation.\n\n# License\n\nLicensed under either of Apache License, Version 2.0 or MIT license at your option.\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukemathwalker%2Fmultipeek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukemathwalker%2Fmultipeek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukemathwalker%2Fmultipeek/lists"}