{"id":29248578,"url":"https://github.com/rstudio-tech/simple-bind","last_synced_at":"2025-07-04T00:08:14.146Z","repository":{"id":302494994,"uuid":"899717860","full_name":"rstudio-tech/simple-bind","owner":"rstudio-tech","description":"Line Simple bind with Rust","archived":false,"fork":false,"pushed_at":"2024-12-06T21:28:11.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-02T17:55:29.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rstudio-tech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2024-12-06T21:27:39.000Z","updated_at":"2024-12-06T21:28:15.000Z","dependencies_parsed_at":"2025-07-02T18:05:36.945Z","dependency_job_id":null,"html_url":"https://github.com/rstudio-tech/simple-bind","commit_stats":null,"previous_names":["rstudio-tech/simple-bind"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rstudio-tech/simple-bind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstudio-tech%2Fsimple-bind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstudio-tech%2Fsimple-bind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstudio-tech%2Fsimple-bind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstudio-tech%2Fsimple-bind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rstudio-tech","download_url":"https://codeload.github.com/rstudio-tech/simple-bind/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstudio-tech%2Fsimple-bind/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421932,"owners_count":23464051,"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","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":[],"created_at":"2025-07-04T00:08:12.433Z","updated_at":"2025-07-04T00:08:14.088Z","avatar_url":"https://github.com/rstudio-tech.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-bind: one-line non-exhaustive binds in Rust\n[![Build Status](https://travis-ci.org/willcrichton/simple-bind.svg?branch=master)](https://travis-ci.org/willcrichton/simple-bind)\n[![](https://img.shields.io/crates/v/simple-bind.svg)](https://crates.io/crates/simple-bind)\n[![](https://docs.rs/simple-bind/badge.svg)](https://docs.rs/simple-bind/)\n\n**Nightly-only crate.**\n\n```rust\n// Here's a brief example that demonstrates how simple-bind works.\n\n#![feature(proc_macro, pattern_parentheses, stmt_expr_attributes)]\nextern crate simple_bind;\nuse simple_bind::bind;\n\nfn main() {\n  enum A { Foo(i32), Bar };\n\n  // Let's say you have a variant of an enum.\n  let x = A::Foo(10);\n\n  // Previously, if you knew `x` was `Foo` and just wanted to access the inside,\n  // you had to do either:\n  let y = match x { A::Foo(y) =\u003e y, _ =\u003e unreachable!() };\n  // or...\n  let y = if let A::Foo(y) = x { y } else { unreachable!() };\n\n  // With simple-bind, you can instead do:\n  bind!{let A::Foo(y) = x;}\n\n  // No more nested match/if statements!\n  assert_eq!(y, 10);\n}\n```\n\n## Setup\n\nUse of this crate uses the unstable `proc_macro` API, so it requires nightly and a few feature gates.\n\nEnable nightly on your repository:\n```\nrustup override set nightly\n```\n\nAdd this line to your `cargo.toml`:\n```toml\n[dependencies]\nsimple-bind = \"0.1.5\"\n```\n\nTo your main module file (`lib.rs` or `main.rs`), add:\n```rust\n#![feature(proc_macro, pattern_parentheses, stmt_expr_attributes)]\nextern crate simple_bind;\n```\n\nThen wherever you want to use the macro, use normal imports (i.e. not `#[macro_use]`):\n```rust\nuse simple_bind::bind;\n```\n\n## Examples\n\n```rust\nfn main() {\n  enum B { Quux(i32) };\n  enum A { Foo(i32), Bar{y: i32}, Baz(B) };\n\n  // Simple binds\n  bind!{let A::Foo(x) = A::Foo(10);}\n\n  // Struct binds\n  let s = A::Bar{y: 1};\n  bind!{let A::Bar{y} = s;}\n\n  // Nested binds\n  bind!{let A::Baz(B::Quux(x)) = A::Baz(B::Quux(10));}\n\n  // Reference binds\n  let mut s = A::Foo(10);\n  bind!{let \u0026mut A::Foo(ref mut y) = \u0026mut s;}\n  *y = 3;\n}\n```\n\n## Issues\n\nThis implementation just covers cases I've run in to, and is not exhaustive to all possible binds. If you find a problem, feel free to submit an issue or a PR!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frstudio-tech%2Fsimple-bind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frstudio-tech%2Fsimple-bind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frstudio-tech%2Fsimple-bind/lists"}