| Crates.io | and_then_some |
| lib.rs | and_then_some |
| version | 1.0.0 |
| created_at | 2020-05-15 17:10:51.957153+00 |
| updated_at | 2020-05-15 17:10:51.957153+00 |
| description | Provides an extension trait for `bool` with methods that return `Option |
| homepage | |
| repository | https://git.sr.ht/~jplatte/and_then_some |
| max_upload_size | |
| id | 242005 |
| size | 6,089 |
Provides an extension trait for bool with methods that return Option<T>.
This crate provides four methods; they all are defined in BoolExt, all take self and another
argument, and all return Option<T>. The only difference is in the type of the second argument:
and: Option<T>and_some: Tand_then: impl FnOnce() -> Option<T>and_then_some: impl FnOnce() -> TI do not consider this crate to be useful myself, I just created it to draw some attention to
the tracking issue for RFC 2757 (methods for converting from bool to Option<T>).
This crate achieves maximum consistency: Some-wrapping is given a _some suffix in the method
names while methods that take a function over a plain value have a _then suffix; and_then is
consistent with Option::and_then in the type of its second argument. This naming scheme results in
the amusing name and_then_some for one of the methods, which made me choose it as the crate name
too. I hope .and_then_some can be stabilized under a different name though, because to me it seems
like the most common out of the four operations.