{"id":31556996,"url":"https://github.com/gamma0987/either-or-both","last_synced_at":"2026-04-26T01:01:29.502Z","repository":{"id":311900593,"uuid":"1036943840","full_name":"gamma0987/either-or-both","owner":"gamma0987","description":"The enums EitherOrBoth with the three variants Left, Right, Both and Either with the Left and Right variants","archived":false,"fork":false,"pushed_at":"2025-08-30T20:28:04.000Z","size":255,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-03T19:37:05.761Z","etag":null,"topics":["bifunctor","combinators","data-structure","deserialization","either","either-or-both","enum","generic-programming","json-schema","no-std","rust","schemars","serde","serde-support","serialization"],"latest_commit_sha":null,"homepage":"https://docs.rs/either-or-both","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gamma0987.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-12T20:20:57.000Z","updated_at":"2025-09-08T09:03:47.000Z","dependencies_parsed_at":"2025-08-27T19:06:07.366Z","dependency_job_id":"bedf98f8-83d5-4afb-9467-77c67a2a001a","html_url":"https://github.com/gamma0987/either-or-both","commit_stats":null,"previous_names":["gamma0987/either-or-both"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/gamma0987/either-or-both","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamma0987%2Feither-or-both","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamma0987%2Feither-or-both/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamma0987%2Feither-or-both/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamma0987%2Feither-or-both/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamma0987","download_url":"https://codeload.github.com/gamma0987/either-or-both/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamma0987%2Feither-or-both/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278386651,"owners_count":25978217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bifunctor","combinators","data-structure","deserialization","either","either-or-both","enum","generic-programming","json-schema","no-std","rust","schemars","serde","serde-support","serialization"],"created_at":"2025-10-04T23:21:07.429Z","updated_at":"2026-04-26T01:01:29.488Z","avatar_url":"https://github.com/gamma0987.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- spell-checker: ignore fixt binstall libtest eprintln usize Gjengset println combinators --\u003e\n\u003c!-- markdownlint-disable MD041 MD033 --\u003e\n\n\u003ch1 align=\"center\"\u003e\u003ccode\u003eEitherOrBoth\u003c/code\u003e and \u003ccode\u003eEither\u003c/code\u003e\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://docs.rs/crate/either-or-both/\"\u003eReleased API Docs\u003c/a\u003e\n    |\n    \u003ca href=\"https://github.com/gamma0987/either-or-both/blob/main/CHANGELOG.md\"\u003eChangelog\u003c/a\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/gamma0987/either-or-both/actions/workflows/cicd.yml\"\u003e\n        \u003cimg\n        src=\"https://github.com/gamma0987/either-or-both/actions/workflows/cicd.yml/badge.svg\"\n        alt=\"GitHub branch checks state\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/gamma0987/either-or-both\" \u003e\n         \u003cimg\n         src=\"https://codecov.io/gh/gamma0987/either-or-both/graph/badge.svg?token=GHG1BMO029\"\n         alt=\"Coverage\"/\u003e\n     \u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/either-or-both\"\u003e\n        \u003cimg src=\"https://img.shields.io/crates/v/either-or-both.svg\" alt=\"Crates.io\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://docs.rs/either-or-both/\"\u003e\n        \u003cimg src=\"https://docs.rs/either-or-both/badge.svg\" alt=\"docs.rs\"/\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003chr\u003e\n\n`either-or-both` provides two enums: [`Either`] and [`EitherOrBoth`].\n\n* **`Either\u003cL, R\u003e`** — a value that is either `Left(L)` or `Right(R)`\n* **`EitherOrBoth\u003cL, R\u003e`** — a value that can be `Left(L)`, `Right(R)`, or `Both(L, R)`\n\nWhile `Either` is useful for representing mutually exclusive values,\n`EitherOrBoth` extends this idea by allowing both values to be present\nsimultaneously.\n\n## Why Use `EitherOrBoth` and `Either`?\n\nIf you often write code like this:\n\n```rust\nmatch options {\n    (Some(left), Some(right)) =\u003e println!(\"Left is: {left}, Right is: {right}\"),\n    (Some(left), None) =\u003e println!(\"Left is: {left}\"),\n    (None, Some(right)) =\u003e println!(\"Right is: {right}\"),\n    (None, None) =\u003e unreachable!(\"Should not happen\"),\n}\n```\n\nYou can **simplify** and **clarify** your intent using `EitherOrBoth`:\n\n* Removes **boilerplate**\n* Improves **readability**\n* Eliminates **unreachable patterns** at compile time\n\nAbstracting over multiple types with `Either`:\n\nSuppose you have a function that returns either an in-memory reader or a\nfile-backed one:\n\n```rust\nfn get_reader(path: Option\u003c\u0026str\u003e) -\u003e Either\u003cCursor\u003cVec\u003cu8\u003e\u003e, File\u003e {\n    match path {\n        Some(p) =\u003e Either::Right(File::open(p).unwrap()),\n        None =\u003e Either::Left(Cursor::new(vec![1, 2, 3])),\n    }\n}\n```\n\nThis allows you to return different types under a **single unified interface**\n(e.g. both implement `Read`), without boxing or trait objects.\n\nUse `Either` when:\n\n* You want to represent **one of two meaningful values**\n* You're modeling **branching logic** that's not necessarily an error case\n* You need to return **different types** while keeping the API ergonomic and type-safe\n\n## Features\n\n* **Intuitive** API inspired by `Option` and functional programming patterns\n* Includes **combinators** like `bimap`, `map`, `and_then`, `apply`, etc.\n* `#![no_std]` compatible (when the `std` feature is disabled)\n* Fully **documented** on [docs.rs](https://docs.rs/either-or-both)\n\n## Installation\n\nAdd `either-or-both` to your `Cargo.toml`:\n\n```toml\n[dependencies]\neither-or-both = \"0.3.1\"\n```\n\nOr use [`cargo add`](https://github.com/killercup/cargo-edit):\n\n```bash\ncargo add either-or-both@0.3.1\n```\n\n## Design Philosophy\n\nThe API for `either-or-both` is heavily inspired by the `Option` type from the\nRust standard library and aims for consistency between the `Either` and\n`EitherOrBoth` enums. Some methods, like `bimap`, are derived from functional\nprogramming languages. Where applicable, methods from `Option` are also\nimplemented for both `Either` and `EitherOrBoth`. Whenever possible, method\nnames with similar functionality are shared across both enums. If you're\nfamiliar with the `Option` API, you'll find the `EitherOrBoth` and `Either`\ninterface intuitive and easy to work with.\n\n## Development Status\n\nThe core API is production-ready.\n\nHowever, as long as the crate version is below `1.0.0`, semver guarantees do not\napply — minor version bumps may include breaking changes.\n\n## License\n\n`either-or-both` is dual licensed under the Apache 2.0 license and the MIT license\nat your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you shall be dual licensed as in\n[License](#license), without any additional terms or conditions.\n\n[`Either`]: https://docs.rs/either-or-both/latest/either_or_both/enum.Either.html\n[`EitherOrBoth`]: https://docs.rs/either-or-both/latest/either_or_both/enum.EitherOrBoth.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamma0987%2Feither-or-both","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamma0987%2Feither-or-both","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamma0987%2Feither-or-both/lists"}