| Crates.io | better_option_result |
| lib.rs | better_option_result |
| version | 0.4.1 |
| created_at | 2025-03-14 23:54:30.124105+00 |
| updated_at | 2025-03-15 03:18:25.698852+00 |
| description | A better Option/Result alternative. |
| homepage | |
| repository | https://github.com/Paladynee/better-option-result |
| max_upload_size | |
| id | 1592860 |
| size | 49,539 |
A library that provides enhanced versions of Rust's Option and Result types with consistent naming conventions.
Rust's standard library Option and Result types have fantastic methods, but their naming conventions are either inconsistent with the rest of the library, or too vague. Some examples include:
Result::is_ok_and and Result::is_err_and vs Option::is_some_and and Option::is_none_or.Option::or do? Can you tell without looking at the signature, just by looking at the name?These drawbacks make it harder to predict and remember method names, especially for newcomers.
For demonstration, try to guess the name of the Result<T, E> method that takes a Result<U, E> and returns another Result,U, E>. With this library, you just need to think what is changed, so in this case, Result::into_ok_of_arg.
In the standard library, the same method is called and, which is more concise, and in its specific context it makes sense, so we have stable aliases for them too.
better_option_result provides drop-in replacements for Option and Result with:
Consistent naming conventions following Rust's own guidelines:
into_* for methods that consume self and transform ownershipas_* for reference-based operationsis_* for boolean checks*_lazy for lazily evaluated operations*_of_arg for operations that return a new type based on the argumentFull backward compatibility with standard library method names:
aliases default feature flag.#![no_std]Add the library using cargo:
cargo add better_option_result
...or add it manually to your Cargo.toml:
[dependencies]
better_option_result = "*"
todo
Option and Result typesContributions are welcome! Please feel free to submit a Pull Request or open an issue on GitHub.
This project is licensed under the MIT License - see the LICENSE file for details.