| 1 |
|
| 2 |
Either |
| 3 |
====== |
| 4 |
|
| 5 |
The enum ``Either`` with variants ``Left`` and ``Right`` and trait |
| 6 |
implementations including Iterator, Read, Write. |
| 7 |
|
| 8 |
Either has methods that are similar to Option and Result. |
| 9 |
|
| 10 |
Includes convenience macros ``try_left!()`` and ``try_right!()`` to use for |
| 11 |
short-circuiting logic. |
| 12 |
|
| 13 |
Please read the `API documentation here`__ |
| 14 |
|
| 15 |
__ https://docs.rs/either/ |
| 16 |
|
| 17 |
|build_status|_ |crates|_ |
| 18 |
|
| 19 |
.. |build_status| image:: https://github.com/rayon-rs/either/workflows/CI/badge.svg?branch=main |
| 20 |
.. _build_status: https://github.com/rayon-rs/either/actions |
| 21 |
|
| 22 |
.. |crates| image:: https://img.shields.io/crates/v/either.svg |
| 23 |
.. _crates: https://crates.io/crates/either |
| 24 |
|
| 25 |
How to use with cargo:: |
| 26 |
|
| 27 |
[dependencies] |
| 28 |
either = "1.11" |
| 29 |
|
| 30 |
|
| 31 |
Recent Changes |
| 32 |
-------------- |
| 33 |
|
| 34 |
- 1.11.0 |
| 35 |
|
| 36 |
- Add new trait ``IntoEither`` that is useful to convert to ``Either`` in method chains, |
| 37 |
by @SFM61319 (#101) |
| 38 |
|
| 39 |
- 1.10.0 |
| 40 |
|
| 41 |
- Add new methods ``.factor_iter()``, ``.factor_iter_mut()``, and ``.factor_into_iter()`` |
| 42 |
that return ``Either`` items, plus ``.iter()`` and ``.iter_mut()`` to convert to direct |
| 43 |
referene iterators; by @aj-bagwell and @cuviper (#91) |
| 44 |
|
| 45 |
- 1.9.0 |
| 46 |
|
| 47 |
- Add new methods ``.map_either()`` and ``.map_either_with()``, by @nasadorian (#82) |
| 48 |
|
| 49 |
- 1.8.1 |
| 50 |
|
| 51 |
- Clarified that the multiple licenses are combined with OR. |
| 52 |
|
| 53 |
- 1.8.0 |
| 54 |
|
| 55 |
- **MSRV**: ``either`` now requires Rust 1.36 or later. |
| 56 |
|
| 57 |
- Add new methods ``.as_pin_ref()`` and ``.as_pin_mut()`` to project a |
| 58 |
pinned ``Either`` as inner ``Pin`` variants, by @cuviper (#77) |
| 59 |
|
| 60 |
- Implement the ``Future`` trait, by @cuviper (#77) |
| 61 |
|
| 62 |
- Specialize more methods of the ``io`` traits, by @Kixunil and @cuviper (#75) |
| 63 |
|
| 64 |
- 1.7.0 |
| 65 |
|
| 66 |
- **MSRV**: ``either`` now requires Rust 1.31 or later. |
| 67 |
|
| 68 |
- Export the macro ``for_both!``, by @thomaseizinger (#58) |
| 69 |
|
| 70 |
- Implement the ``io::Seek`` trait, by @Kerollmops (#60) |
| 71 |
|
| 72 |
- Add new method ``.either_into()`` for ``Into`` conversion, by @TonalidadeHidrica (#63) |
| 73 |
|
| 74 |
- Add new methods ``.factor_ok()``, ``.factor_err()``, and ``.factor_none()``, |
| 75 |
by @zachs18 (#67) |
| 76 |
|
| 77 |
- Specialize ``source`` in the ``Error`` implementation, by @thomaseizinger (#69) |
| 78 |
|
| 79 |
- Specialize more iterator methods and implement the ``FusedIterator`` trait, |
| 80 |
by @Ten0 (#66) and @cuviper (#71) |
| 81 |
|
| 82 |
- Specialize ``Clone::clone_from``, by @cuviper (#72) |
| 83 |
|
| 84 |
- 1.6.1 |
| 85 |
|
| 86 |
- Add new methods ``.expect_left()``, ``.unwrap_left()``, |
| 87 |
and equivalents on the right, by @spenserblack (#51) |
| 88 |
|
| 89 |
- 1.6.0 |
| 90 |
|
| 91 |
- Add new modules ``serde_untagged`` and ``serde_untagged_optional`` to customize |
| 92 |
how ``Either`` fields are serialized in other types, by @MikailBag (#49) |
| 93 |
|
| 94 |
- 1.5.3 |
| 95 |
|
| 96 |
- Add new method ``.map()`` for ``Either<T, T>`` by @nvzqz (#40). |
| 97 |
|
| 98 |
- 1.5.2 |
| 99 |
|
| 100 |
- Add new methods ``.left_or()``, ``.left_or_default()``, ``.left_or_else()``, |
| 101 |
and equivalents on the right, by @DCjanus (#36) |
| 102 |
|
| 103 |
- 1.5.1 |
| 104 |
|
| 105 |
- Add ``AsRef`` and ``AsMut`` implementations for common unsized types: |
| 106 |
``str``, ``[T]``, ``CStr``, ``OsStr``, and ``Path``, by @mexus (#29) |
| 107 |
|
| 108 |
- 1.5.0 |
| 109 |
|
| 110 |
- Add new methods ``.factor_first()``, ``.factor_second()`` and ``.into_inner()`` |
| 111 |
by @mathstuf (#19) |
| 112 |
|
| 113 |
- 1.4.0 |
| 114 |
|
| 115 |
- Add inherent method ``.into_iter()`` by @cuviper (#12) |
| 116 |
|
| 117 |
- 1.3.0 |
| 118 |
|
| 119 |
- Add opt-in serde support by @hcpl |
| 120 |
|
| 121 |
- 1.2.0 |
| 122 |
|
| 123 |
- Add method ``.either_with()`` by @Twey (#13) |
| 124 |
|
| 125 |
- 1.1.0 |
| 126 |
|
| 127 |
- Add methods ``left_and_then``, ``right_and_then`` by @rampantmonkey |
| 128 |
- Include license files in the repository and released crate |
| 129 |
|
| 130 |
- 1.0.3 |
| 131 |
|
| 132 |
- Add crate categories |
| 133 |
|
| 134 |
- 1.0.2 |
| 135 |
|
| 136 |
- Forward more ``Iterator`` methods |
| 137 |
- Implement ``Extend`` for ``Either<L, R>`` if ``L, R`` do. |
| 138 |
|
| 139 |
- 1.0.1 |
| 140 |
|
| 141 |
- Fix ``Iterator`` impl for ``Either`` to forward ``.fold()``. |
| 142 |
|
| 143 |
- 1.0.0 |
| 144 |
|
| 145 |
- Add default crate feature ``use_std`` so that you can opt out of linking to |
| 146 |
std. |
| 147 |
|
| 148 |
- 0.1.7 |
| 149 |
|
| 150 |
- Add methods ``.map_left()``, ``.map_right()`` and ``.either()``. |
| 151 |
- Add more documentation |
| 152 |
|
| 153 |
- 0.1.3 |
| 154 |
|
| 155 |
- Implement Display, Error |
| 156 |
|
| 157 |
- 0.1.2 |
| 158 |
|
| 159 |
- Add macros ``try_left!`` and ``try_right!``. |
| 160 |
|
| 161 |
- 0.1.1 |
| 162 |
|
| 163 |
- Implement Deref, DerefMut |
| 164 |
|
| 165 |
- 0.1.0 |
| 166 |
|
| 167 |
- Initial release |
| 168 |
- Support Iterator, Read, Write |
| 169 |
|
| 170 |
License |
| 171 |
------- |
| 172 |
|
| 173 |
Dual-licensed to be compatible with the Rust project. |
| 174 |
|
| 175 |
Licensed under the Apache License, Version 2.0 |
| 176 |
https://www.apache.org/licenses/LICENSE-2.0 or the MIT license |
| 177 |
https://opensource.org/licenses/MIT, at your |
| 178 |
option. This file may not be copied, modified, or distributed |
| 179 |
except according to those terms. |