{"id":24486055,"url":"https://github.com/zachmatson/bitpatterns","last_synced_at":"2025-03-14T22:12:11.863Z","repository":{"id":57514697,"uuid":"433495543","full_name":"zachmatson/bitpatterns","owner":"zachmatson","description":"Rust library providing simple bitwise pattern testing for integers","archived":false,"fork":false,"pushed_at":"2021-11-30T17:23:27.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T05:24:38.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/zachmatson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-30T16:03:58.000Z","updated_at":"2023-01-13T05:10:29.000Z","dependencies_parsed_at":"2022-09-26T18:00:35.613Z","dependency_job_id":null,"html_url":"https://github.com/zachmatson/bitpatterns","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachmatson%2Fbitpatterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachmatson%2Fbitpatterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachmatson%2Fbitpatterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachmatson%2Fbitpatterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zachmatson","download_url":"https://codeload.github.com/zachmatson/bitpatterns/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243652702,"owners_count":20325611,"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-01-21T14:32:04.704Z","updated_at":"2025-03-14T22:12:11.840Z","avatar_url":"https://github.com/zachmatson.png","language":"Rust","readme":"# bitpatterns\n---\n\n[![Crates.io](https://img.shields.io/crates/v/bitpatterns)](https://crates.io/crates/bitpatterns)\n[![docs.rs](https://img.shields.io/docsrs/bitpatterns)](https://docs.rs/bitpatterns)\n![Crates.io](https://img.shields.io/crates/l/bitpatterns)\n[![Crates.io](https://img.shields.io/crates/d/bitpatterns)](https://crates.io/crates/bitpatterns)\n\nSimple bitwise pattern testing for integers.\n\nProvides functionality to compare integers against patterns of bits which include wildcards.\nPatterns can be declared with convenient macros, the generated code is incredibly small and\nefficient, `no_std`, and the crate depends only on its `bitpatterns-proc-macro`, which itself\nhas *zero* dependencies.\n\nBitwise patterns are stored in the [`BitPattern`] type, which provides the [`is_match`][BitPattern::is_match] method to\ntest for matches. The easiest way to create one of these patterns is with the [`bitpattern!`] macro,\nor the [`is_bit_match!`] macro if the pattern is only being used once.\n\n## Examples\n```rust\nuse bitpatterns::*;\n\n// BitPatterns can be stored as normal variables\nlet pattern_1 = bitpattern!(\"0b1_0..1\");\n// Or even consts\nconst PATTERN_2: BitPattern\u003cu8\u003e = bitpattern!(\"00..1\");\n\n// Now, we can test these patterns against numbers\nassert!(pattern_1.is_match(19)); // 19 == 0b10011\nassert!(!PATTERN_2.is_match(19));\n\nassert!(!pattern_1.is_match(5)); // 5 == 0b00101\nassert!(PATTERN_2.is_match(5));\n\n// Any digits which are not part of the pattern string are automatically\n// treated as wildcards\nassert!(PATTERN_2.is_match(35)); // 35 == 0b100011\n\n// The is_bit_match macro can be used without declaring a pattern variable\nassert!(is_bit_match!(\"101..\", 20)); // 20 == 0b10100\n\n// Using an `as` conversion to compare a number to a pattern of a different\n// size/signedness always works, keeping in mind that bits not specified in\n// the pattern are considered wildcards\nlet pattern_3 = bitpattern!(\"1..01\", u8);\nlet x: i16 = 0b0100_0010_1001_1001;\nassert!(pattern_3.is_match(x as u8));\n```\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)\n* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms or\nconditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachmatson%2Fbitpatterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzachmatson%2Fbitpatterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachmatson%2Fbitpatterns/lists"}