{"id":16856416,"url":"https://github.com/vallentin/every-range","last_synced_at":"2025-10-18T15:23:55.858Z","repository":{"id":57626485,"uuid":"244493741","full_name":"vallentin/every-range","owner":"vallentin","description":"Iterator that \"fill in\" missing ranges, i.e. the gap between two consecutive ranges","archived":false,"fork":false,"pushed_at":"2020-07-12T20:12:44.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-11T12:01:07.725Z","etag":null,"topics":["range","rust","rust-crate","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vallentin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-02T23:00:06.000Z","updated_at":"2020-07-12T20:12:47.000Z","dependencies_parsed_at":"2022-08-31T09:11:37.348Z","dependency_job_id":null,"html_url":"https://github.com/vallentin/every-range","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vallentin/every-range","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fevery-range","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fevery-range/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fevery-range/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fevery-range/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/every-range/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fevery-range/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269905738,"owners_count":24494315,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["range","rust","rust-crate","rust-library"],"created_at":"2024-10-13T14:04:11.270Z","updated_at":"2025-10-18T15:23:55.805Z","avatar_url":"https://github.com/vallentin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# every-range\n\n[![Build Status](https://github.com/vallentin/every-range/workflows/Rust/badge.svg)](https://github.com/vallentin/every-range/actions?query=workflow%3ARust)\n[![Build Status](https://travis-ci.org/vallentin/every-range.svg?branch=master)](https://travis-ci.org/vallentin/every-range)\n[![Latest Version](https://img.shields.io/crates/v/every-range.svg)](https://crates.io/crates/every-range)\n[![Docs](https://docs.rs/every-range/badge.svg)](https://docs.rs/every-range)\n[![License](https://img.shields.io/github/license/vallentin/every-range.svg)](https://github.com/vallentin/every-range)\n\nThis crate implements an extension to [`Iterator`],\nwhich features an [`every_range`] method\non any [`Iterator`] with an [`Item`] of [`Range\u003cusize\u003e`].\n\n[`every_range`]: https://docs.rs/every-range/*/every_range/trait.EveryRange.html#method.every_range\n\n[`Iterator`]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html\n[`Item`]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#associatedtype.Item\n\n[`Range`]: https://doc.rust-lang.org/stable/std/ops/struct.Range.html\n[`Range\u003cusize\u003e`]: https://doc.rust-lang.org/stable/std/ops/struct.Range.html\n\n[`EveryRangeIter`] iterates over [`Range`]s and \"fill in\"\nmissing ranges, i.e. the gap between two consecutive ranges.\nThe original ranges and the generated ones,\ncan be distinguished by the [`Included`] and\n[`Excluded`] enum variants.\n\n[`EveryRangeIter`]: https://docs.rs/every-range/*/every_range/struct.EveryRangeIter.html\n[`Included`]: https://docs.rs/every-range/*/every_range/enum.EveryRangeKind.html#variant.Included\n[`Excluded`]: https://docs.rs/every-range/*/every_range/enum.EveryRangeKind.html#variant.Excluded\n\n[`EveryRangeIter`] is useful when the ranges being iterated\nare related to substrings that later are used to replaced\nparts in a string.\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nevery-range = \"0.1\"\n```\n\n## Releases\n\nRelease notes are available in the repo at [CHANGELOG.md].\n\n[CHANGELOG.md]: CHANGELOG.md\n\n## Example: How does it work?\n\n```rust\nuse every_range::EveryRange;\n\n// Lets use text as an example, but it could be anything\nlet text = \"Foo rust-lang.org Bar\nBaz crates.io Qux\";\n\n// Get some ranges from somewhere\nlet ranges = vec![\n    4..17,  // \"rust-lang.org\"\n    26..35, // \"crates.io\"\n];\n\n// `text.len()` tells `EveryRange` the end, so it knows\n// whether to produce an extra range after or not\nlet iter = ranges.into_iter().every_range(text.len());\n\n// The input `ranges` result in `Included` every other range is `Excluded`\nfor (kind, range) in iter {\n    println!(\"{:?} {:\u003e2?} - {:?}\", kind, range.clone(), \u0026text[range]);\n}\n```\n\nThis will output the following:\n\n```text\nExcluded  0.. 4 - \"Foo \"\nIncluded  4..17 - \"rust-lang.org\"\nExcluded 17..26 - \" Bar\\nBaz \"\nIncluded 26..35 - \"crates.io\"\nExcluded 35..39 - \" Qux\"\n```\n\n## Example: \"Autolink\" or HTMLify URLs\n\nUsing [`every_range`] it is easy to collect ranges or\nsubstring into a [`String`].\n\n[`String`]: https://doc.rust-lang.org/stable/std/string/struct.String.html\n\n```rust\nuse std::borrow::Cow;\nuse every_range::{EveryRange, EveryRangeKind};\n\nlet text = \"Foo rust-lang.org Bar\nBaz crates.io Qux\";\n\n// For URLs input ranges could be produced by linkify\nlet ranges = vec![\n    4..17,  // \"rust-lang.org\"\n    26..35, // \"crates.io\"\n];\n\nlet output = ranges\n    .into_iter()\n    .every_range(text.len())\n    .map(|(kind, range)| {\n        if kind == EveryRangeKind::Included {\n            let url = \u0026text[range];\n            format!(\"\u003ca href=\\\"{0}\\\"\u003e{0}\u003c/a\u003e\", url).into()\n        } else {\n            Cow::Borrowed(\u0026text[range])\n        }\n    })\n    .collect::\u003cVec\u003c_\u003e\u003e()\n    .concat();\n\nprintln!(\"{}\", output);\n```\n\nThis will output the following:\n\n```html\nFoo \u003ca href=\"rust-lang.org\"\u003erust-lang.org\u003c/a\u003e Bar\nBaz \u003ca href=\"crates.io\"\u003ecrates.io\u003c/a\u003e Qux\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fevery-range","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Fevery-range","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fevery-range/lists"}