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