Fallible Map
fallible_map provides utilities for fallible mapping over Option types and iterators, allowing the use of functions that can return Results.
This library includes traits to enhance Option and Iterator types with methods to handle fallible operations gracefully.
Overview
This crate offers extensions for optional values and iterators to perform fallible mapping operations, returning results that properly reflect potential errors during computation.
These extensions can be useful in scenarios where operations may fail, and error handling is required.
Features
- ExtractOption trait: A helper trait to extract the inner value of an optional container;
- FallibleMapExt trait: Extends
Optionwith methods for fallible operations, such astry_map,try_unwrap_or, andtry_and_then; - TryMapIteratorExt trait: Extends iterators with a
try_mapmethod, allowing the use of functions that returnResults during iteration.
Installation
Add this to your Cargo.toml:
[]
= "^0.1"
Usage
Examples
Using FallibleMapExt with Option
use FallibleMapExt;
Using TryMapIteratorExt with Iterator
use TryMapIteratorExt;
Using FallibleMapExt with try_and_then
use FallibleMapExt;
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contribution
Contributions are welcome! Please feel free to submit a pull request, open an issue, or suggest features and improvements.