Skip to content

Commit 94e3bf5

Browse files
committed
Rename back to Fallible, with a different crate name
1 parent be18a71 commit 94e3bf5

File tree

3 files changed

+112
-112
lines changed

3 files changed

+112
-112
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
2-
name = "errable"
2+
name = "fallible-option"
33
version = "0.2.0"
44
authors = ["Mathias Pius <contact@pius.io>"]
5-
description = "Errable is an Option with inverted Try-semantics."
5+
description = "Fallible is an Option with inverted Try-semantics."
66
keywords = ["error-handling", "result", "try"]
7-
repository = "https://github.com/MathiasPius/errable"
7+
repository = "https://github.com/MathiasPius/fallible-option"
88
license = "MIT"
99
edition = "2021"

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
# Errable [![Latest Version]][crates.io] [![Docs]][docs.rs]
1+
# Fallible [![Latest Version]][crates.io] [![Docs]][docs.rs]
22

3-
[Latest Version]: https://img.shields.io/crates/v/errable
4-
[crates.io]: https://crates.io/crates/errable
5-
[Docs]: https://docs.rs/errable/badge.svg
6-
[docs.rs]: https://docs.rs/errable
3+
[Latest Version]: https://img.shields.io/crates/v/fallible-option
4+
[crates.io]: https://crates.io/crates/fallible-option
5+
[Docs]: https://docs.rs/fallible-option/badge.svg
6+
[docs.rs]: https://docs.rs/fallible-option
77

88
<!-- cargo-rdme start -->
99

10-
[`Errable`](https://docs.rs/errable/latest/errable/enum.Errable.html) is an [`Option`](https://doc.rust-lang.org/stable/core/option/enum.Option.html) with inverted [`Try`](https://doc.rust-lang.org/stable/core/ops/trait.Try.html#)-semantics.
10+
[`Fallible`](https://docs.rs/fallible-option/latest/fallible-option/enum.Fallible.html) is an [`Option`](https://doc.rust-lang.org/stable/core/option/enum.Option.html) with inverted [`Try`](https://doc.rust-lang.org/stable/core/ops/trait.Try.html#)-semantics.
1111

12-
What this means is that using the `?` operator on a `Errable<E>` will exit early
12+
What this means is that using the `?` operator on a `Fallible<E>` will exit early
1313
if an error `E` is contained within, or instead act as a no-op, if the value is `Success`.
1414

1515
This is in contrast to `Option` where using `?` on a `None`-value will exit early.
1616

17-
`Errable` fills the gap left by the [`Result`](https://doc.rust-lang.org/stable/core/result/enum.Result.html) and [`Option`](https://doc.rust-lang.org/stable/core/option/enum.Option.html) types:
17+
`Fallible` fills the gap left by the [`Result`](https://doc.rust-lang.org/stable/core/result/enum.Result.html) and [`Option`](https://doc.rust-lang.org/stable/core/option/enum.Option.html) types:
1818

1919
| Potential Success | Potential Failure |
2020
|---------------------|-------------------|
2121
| `Result<T` | `, E>` |
22-
| `Option<T>` | **`Errable<E>`** |
22+
| `Option<T>` | **`Fallible<E>`** |
2323

2424
### Example
25-
This code illustrates how `Errable` can be used to write succint
25+
This code illustrates how `Fallible` can be used to write succint
2626
validation code which exits early in case of failure.
2727

2828
```rust
29-
use errable::Errable::{self, Fail, Success};
29+
use fallible-option::Fallible::{self, Fail, Success};
3030

3131
// Validates the input number `n`, returning a `Fail`
3232
// if the input number is zero, or `Success` otherwise.
33-
fn fails_if_number_is_zero(n: u32) -> Errable<&'static str> {
33+
fn fails_if_number_is_zero(n: u32) -> Fallible<&'static str> {
3434
if n == 0 {
3535
Fail("number is zero")
3636
} else {
@@ -40,7 +40,7 @@ fn fails_if_number_is_zero(n: u32) -> Errable<&'static str> {
4040

4141
// Check many numbers, returning early if a tested
4242
// number is equal to zero.
43-
fn check_many_numbers() -> Errable<&'static str> {
43+
fn check_many_numbers() -> Fallible<&'static str> {
4444
fails_if_number_is_zero(1)?;
4545
fails_if_number_is_zero(3)?;
4646
fails_if_number_is_zero(0)?; // <--- Will cause early exit
@@ -51,13 +51,13 @@ fn check_many_numbers() -> Errable<&'static str> {
5151
Success
5252
}
5353

54-
assert_eq!(check_many_numbers(), Errable::Fail("number is zero"));
54+
assert_eq!(check_many_numbers(), Fallible::Fail("number is zero"));
5555
```
5656

5757
### Motivation
58-
`Errable` fills the gap left by `Option` and `Result` and clearly conveys intent and potential outcomes of a function.
58+
`Fallible` fills the gap left by `Option` and `Result` and clearly conveys intent and potential outcomes of a function.
5959

60-
A function which returns `Errable` has only two potential outcomes, it can fail with an error `E`, or it can succeed.
60+
A function which returns `Fallible` has only two potential outcomes, it can fail with an error `E`, or it can succeed.
6161

6262
#### Why not `Result`?
6363
Because `Result` implies output. Take `std::fs::rename` for instance:
@@ -106,7 +106,7 @@ fn check_many_numbers() -> Option<Error> {
106106
```
107107

108108
### Conversion from `Result`
109-
Switching from using `Result` to `Errable` is very simple, as illustrated with this before/after example:
109+
Switching from using `Result` to `Fallible` is very simple, as illustrated with this before/after example:
110110

111111
```rust
112112
fn validate_number(x: u32) -> Result<(), &'static str> {
@@ -117,10 +117,10 @@ fn validate_number(x: u32) -> Result<(), &'static str> {
117117
}
118118
}
119119
```
120-
Using `Errable`:
120+
Using `Fallible`:
121121

122122
```rust
123-
fn validate_number(x: u32) -> Errable<&'static str> {
123+
fn validate_number(x: u32) -> Fallible<&'static str> {
124124
match x {
125125
0 ..= 9 => Fail("number is too small"),
126126
10..=30 => Success,
@@ -130,11 +130,11 @@ fn validate_number(x: u32) -> Errable<&'static str> {
130130
```
131131
### Compatibility
132132

133-
`Errable` contains utility functions for mapping to and from [`Result`] and [`Option`],
133+
`Fallible` contains utility functions for mapping to and from [`Result`] and [`Option`],
134134
as well as [`FromResidual`] implementations for automatically performing these conversions
135135
when used with the `?` operator.
136136
```rust
137-
fn fails_if_true(should_fail: bool) -> Errable<&'static str> {
137+
fn fails_if_true(should_fail: bool) -> Fallible<&'static str> {
138138
if should_fail {
139139
Fail("Darn it!")
140140
} else {

0 commit comments

Comments
 (0)