• Stars
    star
    377
  • Rank 113,535 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The enum Either with variants Left and Right is a general purpose sum type with two cases.

Either

The enum Either with variants Left and Right and trait implementations including Iterator, Read, Write.

Either has methods that are similar to Option and Result.

Includes convenience macros try_left!() and try_right!() to use for short-circuiting logic.

Please read the API documentation here

build_status crates

How to use with cargo:

[dependencies]
either = "1.8"

Recent Changes

  • 1.8.1
    • Clarified that the multiple licenses are combined with OR.
  • 1.8.0
    • MSRV: either now requires Rust 1.36 or later.
    • Add new methods .as_pin_ref() and .as_pin_mut() to project a pinned Either as inner Pin variants, by @cuviper (#77)
    • Implement the Future trait, by @cuviper (#77)
    • Specialize more methods of the io traits, by @Kixunil and @cuviper (#75)
  • 1.7.0
    • MSRV: either now requires Rust 1.31 or later.
    • Export the macro for_both!, by @thomaseizinger (#58)
    • Implement the io::Seek trait, by @Kerollmops (#60)
    • Add new method .either_into() for Into conversion, by @TonalidadeHidrica (#63)
    • Add new methods .factor_ok(), .factor_err(), and .factor_none(), by @zachs18 (#67)
    • Specialize source in the Error implementation, by @thomaseizinger (#69)
    • Specialize more iterator methods and implement the FusedIterator trait, by @Ten0 (#66) and @cuviper (#71)
    • Specialize Clone::clone_from, by @cuviper (#72)
  • 1.6.1
    • Add new methods .expect_left(), .unwrap_left(), and equivalents on the right, by @spenserblack (#51)
  • 1.6.0
    • Add new modules serde_untagged and serde_untagged_optional to customize how Either fields are serialized in other types, by @MikailBag (#49)
  • 1.5.3
    • Add new method .map() for Either<T, T> by @nvzqz (#40).
  • 1.5.2
    • Add new methods .left_or(), .left_or_default(), .left_or_else(), and equivalents on the right, by @DCjanus (#36)
  • 1.5.1
    • Add AsRef and AsMut implementations for common unsized types: str, [T], CStr, OsStr, and Path, by @mexus (#29)
  • 1.5.0
    • Add new methods .factor_first(), .factor_second() and .into_inner() by @mathstuf (#19)
  • 1.4.0
    • Add inherent method .into_iter() by @cuviper (#12)
  • 1.3.0
    • Add opt-in serde support by @hcpl
  • 1.2.0
    • Add method .either_with() by @Twey (#13)
  • 1.1.0
    • Add methods left_and_then, right_and_then by @rampantmonkey
    • Include license files in the repository and released crate
  • 1.0.3
    • Add crate categories
  • 1.0.2
    • Forward more Iterator methods
    • Implement Extend for Either<L, R> if L, R do.
  • 1.0.1
    • Fix Iterator impl for Either to forward .fold().
  • 1.0.0
    • Add default crate feature use_std so that you can opt out of linking to std.
  • 0.1.7
    • Add methods .map_left(), .map_right() and .either().
    • Add more documentation
  • 0.1.3
    • Implement Display, Error
  • 0.1.2
    • Add macros try_left! and try_right!.
  • 0.1.1
    • Implement Deref, DerefMut
  • 0.1.0
    • Initial release
    • Support Iterator, Read, Write

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 or the MIT license https://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

More Repositories

1

indexmap

A hash table with consistent order and fast iteration; access items by key or sequence index
Rust
1,361
star
2

arrayvec

A vector with a fixed capacity. (Rust)
Rust
714
star
3

scopeguard

Rust crate for a convenient RAII scope guard.
Rust
429
star
4

maplit

Rust container / collection literal macros for HashMap, HashSet, BTreeMap, BTreeSet.
Rust
378
star
5

matrixmultiply

General matrix multiplication of f32 and f64 matrices in Rust. Supports matrices with general strides.
Rust
206
star
6

indexing

Sound unchecked indexing using “generativity”; a type system approach to indices, pointers and ranges that are trusted to be in bounds.
Rust
100
star
7

bencher

bencher is just a port of the libtest (unstable) benchmark runner to Rust stable releases. `cargo bench` on stable. "Not a better bencher!" = No feature development. Go build a better stable benchmarking library.
Rust
83
star
8

twoway

Twoway / Fast substring search for strings and byte strings (Rust) / Also assorted benchmarks and string search snippets
Rust
65
star
9

permutohedron

Rust
36
star
10

rustfaq

Bluss' Rust FAQ, intended to answer questions that are often encountered, and being simple to update. There's quite a lot of editing needed to get to a useful FAQ, so we'll see if we get there.
30
star
11

odds

Odds and ends — collection miscellania. Extra functionality for slices, strings and other things
Rust
21
star
12

fast-floats

Experimental (unstable) “fast-math” wrappers for f32, f64
Rust
19
star
13

pyproject-local-kernel

Python Jupyter kernel using pyproject environment manangers like Rye, Uv, PDM, Poetry, Hatch etc.
Python
15
star
14

defmac

A macro to define lambda-like macros inline.
Rust
15
star
15

ixlist

The “ixlist” is a linked list in a vector
Rust
11
star
16

itertools-num

[looking for adoption of the crate] Numerics iterator tools; cumulative sum and linearly spaced floats and such.
Rust
10
star
17

debugit

DebugIt: Use specialization so you can debug-print a value without explicit (and viral) Debug trait bound. (Not really maintained. Uses specialization so it may break)
Rust
10
star
18

thread-tree

A tree-shaped thread pool used for spawning stack-bound scoped jobs with no work stealing. Derived from a little bit of rayon-core code + new thread pool on top.
Rust
10
star
19

tox-rye

Use Rye to discover or fetch Python versions for Tox (v4)
Python
7
star
20

unchecked-index

Unchecked indexing and debug-assertion checked indexing through the regular index syntax.
Rust
7
star
21

qc.rs

quickcheck for Rust
Rust
6
star
22

simplesvg

Very simple drawing/diagramming library with svg output (Rust).
Rust
6
star
23

virtualenv-rye-discovery

Virtualenv plugin for discovery of Python interpreters through Rye.
Python
5
star
24

ryeish-kernel

Python Jupyter kernel using Rye for reproducible notebooks
Python
5
star
25

knuth-morris-pratt

Generic substring search for sequences. Requires elements that are equality comparable.
Rust
5
star
26

galil-seiferas

Galil-Seiferas algorithm: String search in constant space, linear time, for nonorderable alphabets
Rust
5
star
27

rawpointer

Extra methods for raw pointers
Rust
4
star
28

dlx

Dancing Links (“dlx”) solver for the exact cover problem, written in Rust. Can be used to create a sudoku solver.
Rust
4
star
29

rpasha

Restrictive Precise Angle Shadowcasting, a field of view algorithm for a discrete playing field.
Rust
4
star
30

rawslice

Rust
2
star
31

siphash-ppc-altivec

C
2
star
32

asprim

Rust library with a trait for the `as` operator for primitive numeric types.
Rust
2
star
33

blake2-ppc-altivec

BLAKE2s hash function https://blake2.net PowerPC/Altivec implementation by Ulrik Sverdrup
C
2
star
34

trait-group

Rust
2
star
35

blis-sys

[Feel free to adopt/fork this repo!] Experimental Rust bindings for BLIS
Rust
2
star
36

bmap

Experimental B-tree map in Rust using ArrayVec
Rust
1
star
37

rand_derive

(Obsolete) derive(Rand) for use with custom_derive!{}. Works with stable Rust 1.8+
Rust
1
star
38

numeric-loops

Rust
1
star
39

complexfloat

Extended traits for Rust Float and Complex types. Requires Rust 1.8.
Rust
1
star
40

bluss.github.io

HTML
1
star