Crates.io | try-iterator |
lib.rs | try-iterator |
version | 1.0.0 |
source | src |
created_at | 2024-04-01 12:30:25.868782 |
updated_at | 2024-04-01 12:30:25.868782 |
description | Adds a few fallible methods to iterators. |
homepage | |
repository | https://github.com/rodrigocfd/try-iterator |
max_upload_size | |
id | 1192467 |
size | 16,450 |
Implements the TryIterator
trait, which will add the following fallible methods to Iterator
:
New method | Analog to |
---|---|
try_all |
all |
try_any |
any |
try_position |
position |
try_rposition |
rposition |
This crate was born out of necessity of a fallible version for the Iterator::position
method, which was asked in this StackOverflow question. Contrary to the equivalent try_for_each
, the solution is rather cumbersome, which resulted in this issue in the Rust repository.
Until the standard library adds these fallible methods – if ever –, they are available in this crate.
Add the dependency in your Cargo.toml
:
[dependencies]
try-iterator = { version = "1.0.0" }
Then import the prelude
at the top of your source files:
use try_iterator::prelude::*;
The new methods will be automatically present in Iterator
.
Licensed under MIT license, see LICENSE.md for details.