Convert Option to Result
Overview
assert_eq!;
assert_eq!;
This crate provides a generic NotFoundError<T> type and associated
utilities for handling “not found” scenarios in a type-safe and ergonomic manner.
You can convert Option<T> to Result<T, NotFoundError<T> using require function or Require extension trait.
You can convert Option<T> to Result<T, NotFoundError<AnotherType> using not_found function or OkOrNotFound extension trait.
Features
- Generic
NotFoundError<T>type - Conversion functions and traits to transform
Option<T>intoResult<T, NotFoundError<T>> - Conversion functions and traits to transform
Option<T>intoResult<T, NotFoundError<AnotherType>>
Examples
use ;
let item = require;
assert_eq!;
let item = require;
assert_eq!;
// Using the `require` extension method
let item = .into_iter.next.require;
assert_eq!;
let item = .into_iter.next.require;
assert_eq!;
Installation
cargo add not-found-error
Gratitude
Like the project? Say thanks! ❤️
License
Apache License 2.0 or MIT License at your option.
Unless 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.