diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d330888..82aa2f9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,7 +19,7 @@ jobs: format: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Install latest uses: actions-rs/toolchain@v1 with: @@ -31,7 +31,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Install latest uses: actions-rs/toolchain@v1 with: @@ -45,7 +45,7 @@ jobs: clippy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Install latest uses: actions-rs/toolchain@v1 with: @@ -62,7 +62,7 @@ jobs: runs-on: ubuntu-latest if: github.ref != 'refs/heads/main' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 with: ref: refs/heads/${{ github.head_ref }} persist-credentials: false @@ -98,7 +98,7 @@ jobs: - test - clippy steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -124,7 +124,7 @@ jobs: - test - clippy steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - uses: actions-rs/toolchain@v1 with: toolchain: stable diff --git a/docs/.rustc_info.json b/docs/.rustc_info.json index 2421181..427b7e4 100644 --- a/docs/.rustc_info.json +++ b/docs/.rustc_info.json @@ -1 +1 @@ -{"rustc_fingerprint":13690027882614928059,"outputs":{"17598535894874457435":{"success":true,"status":"","code":0,"stdout":"rustc 1.60.0 (7737e0b5c 2022-04-04)\nbinary: rustc\ncommit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\ncommit-date: 2022-04-04\nhost: x86_64-unknown-linux-gnu\nrelease: 1.60.0\nLLVM version: 14.0.0\n","stderr":""},"2797684049618456168":{"success":false,"status":"exit status: 1","code":1,"stdout":"","stderr":"error: `-Csplit-debuginfo` is unstable on this platform\n\n"},"5309432699494263626":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n","stderr":""},"931469667778813386":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}} \ No newline at end of file +{"rustc_fingerprint":1195818914113442546,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.91.1 (ed61e7d7e 2025-11-07)\nbinary: rustc\ncommit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb\ncommit-date: 2025-11-07\nhost: x86_64-unknown-linux-gnu\nrelease: 1.91.1\nLLVM version: 21.1.2\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/docs/.rustdoc_fingerprint.json b/docs/.rustdoc_fingerprint.json index 39f4ce4..45fa64e 100644 --- a/docs/.rustdoc_fingerprint.json +++ b/docs/.rustdoc_fingerprint.json @@ -1 +1 @@ -{"rustc_vv":"rustc 1.60.0 (7737e0b5c 2022-04-04)\nbinary: rustc\ncommit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c\ncommit-date: 2022-04-04\nhost: x86_64-unknown-linux-gnu\nrelease: 1.60.0\nLLVM version: 14.0.0\n"} \ No newline at end of file +{"rustc_vv":"rustc 1.91.1 (ed61e7d7e 2025-11-07)\nbinary: rustc\ncommit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb\ncommit-date: 2025-11-07\nhost: x86_64-unknown-linux-gnu\nrelease: 1.91.1\nLLVM version: 21.1.2\n"} \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/build-script-build-script-build b/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/build-script-build-script-build new file mode 100644 index 0000000..50ef9aa --- /dev/null +++ b/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/build-script-build-script-build @@ -0,0 +1 @@ +cfb34e5ef1ed884e \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/build-script-build-script-build.json b/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/build-script-build-script-build.json new file mode 100644 index 0000000..bc94539 --- /dev/null +++ b/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/build-script-build-script-build.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"[]","declared_features":"[\"no_core\", \"old_macros\"]","target":12318548087768197662,"profile":2225463790103693989,"path":15706683084274424270,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/doc-comment-16a6f021619eaad7/dep-build-script-build-script-build","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/dep-build-script-build-script-build b/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/dep-build-script-build-script-build new file mode 100644 index 0000000..ec3cb8b Binary files /dev/null and b/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/dep-build-script-build-script-build differ diff --git a/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/invoked.timestamp b/docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/invoked.timestamp similarity index 100% rename from docs/debug/.fingerprint/doc-comment-ab83651059ca7977/invoked.timestamp rename to docs/debug/.fingerprint/doc-comment-16a6f021619eaad7/invoked.timestamp diff --git a/docs/debug/.fingerprint/doc-comment-1b06897278944c90/run-build-script-build-script-build b/docs/debug/.fingerprint/doc-comment-1b06897278944c90/run-build-script-build-script-build deleted file mode 100644 index 4322295..0000000 --- a/docs/debug/.fingerprint/doc-comment-1b06897278944c90/run-build-script-build-script-build +++ /dev/null @@ -1 +0,0 @@ -4d6870b2301f6e96 \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-1b06897278944c90/run-build-script-build-script-build.json b/docs/debug/.fingerprint/doc-comment-1b06897278944c90/run-build-script-build-script-build.json deleted file mode 100644 index db005a1..0000000 --- a/docs/debug/.fingerprint/doc-comment-1b06897278944c90/run-build-script-build-script-build.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":6064785002308032717,"features":"","target":0,"profile":0,"path":0,"deps":[[3604316984868239912,"build_script_build",false,11046353864905882589]],"local":[{"Precalculated":"0.3.3"}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-87fa1f73bab2947c/run-build-script-build-script-build b/docs/debug/.fingerprint/doc-comment-87fa1f73bab2947c/run-build-script-build-script-build new file mode 100644 index 0000000..adfffa2 --- /dev/null +++ b/docs/debug/.fingerprint/doc-comment-87fa1f73bab2947c/run-build-script-build-script-build @@ -0,0 +1 @@ +86aea2787ce3c0c3 \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-87fa1f73bab2947c/run-build-script-build-script-build.json b/docs/debug/.fingerprint/doc-comment-87fa1f73bab2947c/run-build-script-build-script-build.json new file mode 100644 index 0000000..759b23e --- /dev/null +++ b/docs/debug/.fingerprint/doc-comment-87fa1f73bab2947c/run-build-script-build-script-build.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"","declared_features":"","target":0,"profile":0,"path":0,"deps":[[4722856061491664201,"build_script_build",false,5659034552716145615]],"local":[{"Precalculated":"0.3.4"}],"rustflags":[],"config":0,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/build-script-build-script-build b/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/build-script-build-script-build deleted file mode 100644 index 1d7c0b0..0000000 --- a/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/build-script-build-script-build +++ /dev/null @@ -1 +0,0 @@ -dd7bfa6450884c99 \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/build-script-build-script-build.json b/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/build-script-build-script-build.json deleted file mode 100644 index 88c66cc..0000000 --- a/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/build-script-build-script-build.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":6064785002308032717,"features":"[]","target":2709041430195671023,"profile":12637318739757120569,"path":6418153070291560974,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/doc-comment-ab83651059ca7977/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":2009847191618272438,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/dep-build-script-build-script-build b/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/dep-build-script-build-script-build deleted file mode 100644 index 1b1cb4d..0000000 Binary files a/docs/debug/.fingerprint/doc-comment-ab83651059ca7977/dep-build-script-build-script-build and /dev/null differ diff --git a/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/dep-lib-doc_comment b/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/dep-lib-doc_comment deleted file mode 100644 index 1b1cb4d..0000000 Binary files a/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/dep-lib-doc_comment and /dev/null differ diff --git a/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/lib-doc_comment b/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/lib-doc_comment deleted file mode 100644 index 7df5a2d..0000000 --- a/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/lib-doc_comment +++ /dev/null @@ -1 +0,0 @@ -29b51fa956307754 \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/lib-doc_comment.json b/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/lib-doc_comment.json deleted file mode 100644 index b8e3148..0000000 --- a/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/lib-doc_comment.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":6064785002308032717,"features":"[]","target":3927201586341892043,"profile":3735503092003429423,"path":9436458717181895228,"deps":[[3604316984868239912,"build_script_build",false,10839635647139965005]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/doc-comment-bda2383960759dfa/dep-lib-doc_comment"}}],"rustflags":[],"metadata":2009847191618272438,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/dep-lib-doc_comment b/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/dep-lib-doc_comment new file mode 100644 index 0000000..ec3cb8b Binary files /dev/null and b/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/dep-lib-doc_comment differ diff --git a/docs/debug/.fingerprint/doc-comment-bda2383960759dfa/invoked.timestamp b/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/invoked.timestamp similarity index 100% rename from docs/debug/.fingerprint/doc-comment-bda2383960759dfa/invoked.timestamp rename to docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/invoked.timestamp diff --git a/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/lib-doc_comment b/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/lib-doc_comment new file mode 100644 index 0000000..becad7a --- /dev/null +++ b/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/lib-doc_comment @@ -0,0 +1 @@ +eb903067ca5ee000 \ No newline at end of file diff --git a/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/lib-doc_comment.json b/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/lib-doc_comment.json new file mode 100644 index 0000000..6173c77 --- /dev/null +++ b/docs/debug/.fingerprint/doc-comment-db0e63784ee930b3/lib-doc_comment.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"[]","declared_features":"[\"no_core\", \"old_macros\"]","target":919102347318276249,"profile":2241668132362809309,"path":5501992716707089722,"deps":[[4722856061491664201,"build_script_build",false,14105524156663770758]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/doc-comment-db0e63784ee930b3/dep-lib-doc_comment","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/dep-lib-paste b/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/dep-lib-paste deleted file mode 100644 index 1b1cb4d..0000000 Binary files a/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/dep-lib-paste and /dev/null differ diff --git a/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/lib-paste b/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/lib-paste deleted file mode 100644 index a8289e9..0000000 --- a/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/lib-paste +++ /dev/null @@ -1 +0,0 @@ -5190ddf878d108e5 \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/lib-paste.json b/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/lib-paste.json deleted file mode 100644 index 8e08d12..0000000 --- a/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/lib-paste.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":6064785002308032717,"features":"[]","target":11680813067107455742,"profile":12637318739757120569,"path":6270110714609130184,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/paste-20ebc6fd9e2b3438/dep-lib-paste"}}],"rustflags":[],"metadata":13015013502493569352,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-220e914fdb601d92/build-script-build-script-build b/docs/debug/.fingerprint/paste-220e914fdb601d92/build-script-build-script-build new file mode 100644 index 0000000..f5dc107 --- /dev/null +++ b/docs/debug/.fingerprint/paste-220e914fdb601d92/build-script-build-script-build @@ -0,0 +1 @@ +ccc98c366f3f219f \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-220e914fdb601d92/build-script-build-script-build.json b/docs/debug/.fingerprint/paste-220e914fdb601d92/build-script-build-script-build.json new file mode 100644 index 0000000..3f88d0c --- /dev/null +++ b/docs/debug/.fingerprint/paste-220e914fdb601d92/build-script-build-script-build.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"[]","declared_features":"[]","target":17883862002600103897,"profile":2225463790103693989,"path":7755287703248029529,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/paste-220e914fdb601d92/dep-build-script-build-script-build","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-220e914fdb601d92/dep-build-script-build-script-build b/docs/debug/.fingerprint/paste-220e914fdb601d92/dep-build-script-build-script-build new file mode 100644 index 0000000..ec3cb8b Binary files /dev/null and b/docs/debug/.fingerprint/paste-220e914fdb601d92/dep-build-script-build-script-build differ diff --git a/docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/invoked.timestamp b/docs/debug/.fingerprint/paste-220e914fdb601d92/invoked.timestamp similarity index 100% rename from docs/debug/.fingerprint/paste-20ebc6fd9e2b3438/invoked.timestamp rename to docs/debug/.fingerprint/paste-220e914fdb601d92/invoked.timestamp diff --git a/docs/debug/.fingerprint/paste-45ae09343cbe966a/dep-lib-paste b/docs/debug/.fingerprint/paste-45ae09343cbe966a/dep-lib-paste new file mode 100644 index 0000000..ec3cb8b Binary files /dev/null and b/docs/debug/.fingerprint/paste-45ae09343cbe966a/dep-lib-paste differ diff --git a/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/invoked.timestamp b/docs/debug/.fingerprint/paste-45ae09343cbe966a/invoked.timestamp similarity index 100% rename from docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/invoked.timestamp rename to docs/debug/.fingerprint/paste-45ae09343cbe966a/invoked.timestamp diff --git a/docs/debug/.fingerprint/paste-45ae09343cbe966a/lib-paste b/docs/debug/.fingerprint/paste-45ae09343cbe966a/lib-paste new file mode 100644 index 0000000..cd01095 --- /dev/null +++ b/docs/debug/.fingerprint/paste-45ae09343cbe966a/lib-paste @@ -0,0 +1 @@ +fae8371381ea471c \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-45ae09343cbe966a/lib-paste.json b/docs/debug/.fingerprint/paste-45ae09343cbe966a/lib-paste.json new file mode 100644 index 0000000..d863045 --- /dev/null +++ b/docs/debug/.fingerprint/paste-45ae09343cbe966a/lib-paste.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"[]","declared_features":"[]","target":13051495773103412369,"profile":2225463790103693989,"path":14344750008970667249,"deps":[[17605717126308396068,"build_script_build",false,18219006255417299869]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/paste-45ae09343cbe966a/dep-lib-paste","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-5e5c6d03f89d0c51/run-build-script-build-script-build b/docs/debug/.fingerprint/paste-5e5c6d03f89d0c51/run-build-script-build-script-build new file mode 100644 index 0000000..c7de2bb --- /dev/null +++ b/docs/debug/.fingerprint/paste-5e5c6d03f89d0c51/run-build-script-build-script-build @@ -0,0 +1 @@ +9d93c42ea9e9d6fc \ No newline at end of file diff --git a/docs/debug/.fingerprint/paste-5e5c6d03f89d0c51/run-build-script-build-script-build.json b/docs/debug/.fingerprint/paste-5e5c6d03f89d0c51/run-build-script-build-script-build.json new file mode 100644 index 0000000..e91c6f3 --- /dev/null +++ b/docs/debug/.fingerprint/paste-5e5c6d03f89d0c51/run-build-script-build-script-build.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"","declared_features":"","target":0,"profile":0,"path":0,"deps":[[17605717126308396068,"build_script_build",false,11466515873151109580]],"local":[{"RerunIfChanged":{"output":"debug/build/paste-5e5c6d03f89d0c51/output","paths":["build.rs"]}}],"rustflags":[],"config":0,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/dep-lib-safe-transmute b/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/dep-lib-safe-transmute deleted file mode 100644 index 1b1cb4d..0000000 Binary files a/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/dep-lib-safe-transmute and /dev/null differ diff --git a/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/lib-safe-transmute b/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/lib-safe-transmute deleted file mode 100644 index 4ae79fd..0000000 --- a/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/lib-safe-transmute +++ /dev/null @@ -1 +0,0 @@ -20d79b6bd636334e \ No newline at end of file diff --git a/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/lib-safe-transmute.json b/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/lib-safe-transmute.json deleted file mode 100644 index 79adf8a..0000000 --- a/docs/debug/.fingerprint/safe-transmute-08de2e97acce0a0b/lib-safe-transmute.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":6064785002308032717,"features":"[\"alloc\", \"default\", \"std\"]","target":53543228631905795,"profile":3735503092003429423,"path":3574858853815873827,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/safe-transmute-08de2e97acce0a0b/dep-lib-safe-transmute"}}],"rustflags":[],"metadata":1405137643048346262,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/safe-transmute-323d820241496e09/dep-lib-safe_transmute b/docs/debug/.fingerprint/safe-transmute-323d820241496e09/dep-lib-safe_transmute new file mode 100644 index 0000000..ec3cb8b Binary files /dev/null and b/docs/debug/.fingerprint/safe-transmute-323d820241496e09/dep-lib-safe_transmute differ diff --git a/docs/debug/build/doc-comment-1b06897278944c90/invoked.timestamp b/docs/debug/.fingerprint/safe-transmute-323d820241496e09/invoked.timestamp similarity index 100% rename from docs/debug/build/doc-comment-1b06897278944c90/invoked.timestamp rename to docs/debug/.fingerprint/safe-transmute-323d820241496e09/invoked.timestamp diff --git a/docs/debug/.fingerprint/safe-transmute-323d820241496e09/lib-safe_transmute b/docs/debug/.fingerprint/safe-transmute-323d820241496e09/lib-safe_transmute new file mode 100644 index 0000000..a65e806 --- /dev/null +++ b/docs/debug/.fingerprint/safe-transmute-323d820241496e09/lib-safe_transmute @@ -0,0 +1 @@ +6c7805651e976316 \ No newline at end of file diff --git a/docs/debug/.fingerprint/safe-transmute-323d820241496e09/lib-safe_transmute.json b/docs/debug/.fingerprint/safe-transmute-323d820241496e09/lib-safe_transmute.json new file mode 100644 index 0000000..ba324bf --- /dev/null +++ b/docs/debug/.fingerprint/safe-transmute-323d820241496e09/lib-safe_transmute.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"[\"alloc\", \"default\", \"std\"]","declared_features":"[\"alloc\", \"const_generics\", \"default\", \"std\"]","target":18003846427605080374,"profile":2241668132362809309,"path":3381536200770839992,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/safe-transmute-323d820241496e09/dep-lib-safe_transmute","checksum":false}}],"rustflags":[],"config":2069994364910194474,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/ubits-5cb737df32df7532/doc-lib-ubits b/docs/debug/.fingerprint/ubits-5cb737df32df7532/doc-lib-ubits deleted file mode 100644 index c71b050..0000000 --- a/docs/debug/.fingerprint/ubits-5cb737df32df7532/doc-lib-ubits +++ /dev/null @@ -1 +0,0 @@ -0557fa1f5a0f2882 \ No newline at end of file diff --git a/docs/debug/.fingerprint/ubits-5cb737df32df7532/doc-lib-ubits.json b/docs/debug/.fingerprint/ubits-5cb737df32df7532/doc-lib-ubits.json deleted file mode 100644 index cf264ed..0000000 --- a/docs/debug/.fingerprint/ubits-5cb737df32df7532/doc-lib-ubits.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":6064785002308032717,"features":"[]","target":2709273923335524737,"profile":13883289224548942237,"path":17523903030608720598,"deps":[[3604316984868239912,"doc_comment",false,6086386570177262889],[17122623820282837837,"safe_transmute",false,5634907853326898976],[17738545360000146463,"paste",false,16503671152000733265]],"local":[{"Precalculated":"1651601534.138340045s (docs/.rustc_info.json)"}],"rustflags":[],"metadata":3531897852417656932,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/doc-lib-ubits b/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/doc-lib-ubits new file mode 100644 index 0000000..4b1bc19 --- /dev/null +++ b/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/doc-lib-ubits @@ -0,0 +1 @@ +ddc28e5657fc0c23 \ No newline at end of file diff --git a/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/doc-lib-ubits.json b/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/doc-lib-ubits.json new file mode 100644 index 0000000..bd49cf2 --- /dev/null +++ b/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/doc-lib-ubits.json @@ -0,0 +1 @@ +{"rustc":4826714390000139368,"features":"[]","declared_features":"[]","target":4895282625946509461,"profile":4625255726265738819,"path":10763286916239946207,"deps":[[4722856061491664201,"doc_comment",false,63154618190827755],[17496040597546035961,"safe_transmute",false,1613299248328439916],[17605717126308396068,"paste",false,2037855196502550778]],"local":[{"Precalculated":"1763658268.946029039s (docs/debug/.cargo-lock)"}],"rustflags":[],"config":2069994364910194474,"compile_kind":0} \ No newline at end of file diff --git a/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/invoked.timestamp b/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/docs/debug/.fingerprint/ubits-d0f4991a0b8f298b/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/docs/debug/build/doc-comment-16a6f021619eaad7/build-script-build b/docs/debug/build/doc-comment-16a6f021619eaad7/build-script-build new file mode 100755 index 0000000..1d8cc6d Binary files /dev/null and b/docs/debug/build/doc-comment-16a6f021619eaad7/build-script-build differ diff --git a/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7 b/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7 new file mode 100755 index 0000000..1d8cc6d Binary files /dev/null and b/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7 differ diff --git a/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7.d b/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7.d new file mode 100644 index 0000000..63d16da --- /dev/null +++ b/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7.d @@ -0,0 +1,5 @@ +/home/runner/work/ubits/ubits/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7.d: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/doc-comment-0.3.4/build.rs + +/home/runner/work/ubits/ubits/docs/debug/build/doc-comment-16a6f021619eaad7/build_script_build-16a6f021619eaad7: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/doc-comment-0.3.4/build.rs + +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/doc-comment-0.3.4/build.rs: diff --git a/docs/debug/build/doc-comment-1b06897278944c90/root-output b/docs/debug/build/doc-comment-1b06897278944c90/root-output deleted file mode 100644 index be44112..0000000 --- a/docs/debug/build/doc-comment-1b06897278944c90/root-output +++ /dev/null @@ -1 +0,0 @@ -/home/runner/work/ubits/ubits/docs/debug/build/doc-comment-1b06897278944c90/out \ No newline at end of file diff --git a/docs/debug/build/doc-comment-87fa1f73bab2947c/invoked.timestamp b/docs/debug/build/doc-comment-87fa1f73bab2947c/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/docs/debug/build/doc-comment-87fa1f73bab2947c/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/docs/debug/build/doc-comment-1b06897278944c90/output b/docs/debug/build/doc-comment-87fa1f73bab2947c/output similarity index 100% rename from docs/debug/build/doc-comment-1b06897278944c90/output rename to docs/debug/build/doc-comment-87fa1f73bab2947c/output diff --git a/docs/debug/build/doc-comment-87fa1f73bab2947c/root-output b/docs/debug/build/doc-comment-87fa1f73bab2947c/root-output new file mode 100644 index 0000000..51f852f --- /dev/null +++ b/docs/debug/build/doc-comment-87fa1f73bab2947c/root-output @@ -0,0 +1 @@ +/home/runner/work/ubits/ubits/docs/debug/build/doc-comment-87fa1f73bab2947c/out \ No newline at end of file diff --git a/docs/debug/build/doc-comment-1b06897278944c90/stderr b/docs/debug/build/doc-comment-87fa1f73bab2947c/stderr similarity index 100% rename from docs/debug/build/doc-comment-1b06897278944c90/stderr rename to docs/debug/build/doc-comment-87fa1f73bab2947c/stderr diff --git a/docs/debug/build/doc-comment-ab83651059ca7977/build-script-build b/docs/debug/build/doc-comment-ab83651059ca7977/build-script-build deleted file mode 100755 index ff6382a..0000000 Binary files a/docs/debug/build/doc-comment-ab83651059ca7977/build-script-build and /dev/null differ diff --git a/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977 b/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977 deleted file mode 100755 index ff6382a..0000000 Binary files a/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977 and /dev/null differ diff --git a/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977.d b/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977.d deleted file mode 100644 index db88898..0000000 --- a/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977.d +++ /dev/null @@ -1,5 +0,0 @@ -/home/runner/work/ubits/ubits/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/doc-comment-0.3.3/build.rs - -/home/runner/work/ubits/ubits/docs/debug/build/doc-comment-ab83651059ca7977/build_script_build-ab83651059ca7977.d: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/doc-comment-0.3.3/build.rs - -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/doc-comment-0.3.3/build.rs: diff --git a/docs/debug/build/paste-220e914fdb601d92/build-script-build b/docs/debug/build/paste-220e914fdb601d92/build-script-build new file mode 100755 index 0000000..118bc7f Binary files /dev/null and b/docs/debug/build/paste-220e914fdb601d92/build-script-build differ diff --git a/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92 b/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92 new file mode 100755 index 0000000..118bc7f Binary files /dev/null and b/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92 differ diff --git a/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92.d b/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92.d new file mode 100644 index 0000000..0f90223 --- /dev/null +++ b/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92.d @@ -0,0 +1,5 @@ +/home/runner/work/ubits/ubits/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92.d: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/build.rs + +/home/runner/work/ubits/ubits/docs/debug/build/paste-220e914fdb601d92/build_script_build-220e914fdb601d92: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/build.rs + +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/build.rs: diff --git a/docs/debug/build/paste-5e5c6d03f89d0c51/invoked.timestamp b/docs/debug/build/paste-5e5c6d03f89d0c51/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/docs/debug/build/paste-5e5c6d03f89d0c51/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/docs/debug/build/paste-5e5c6d03f89d0c51/output b/docs/debug/build/paste-5e5c6d03f89d0c51/output new file mode 100644 index 0000000..738185c --- /dev/null +++ b/docs/debug/build/paste-5e5c6d03f89d0c51/output @@ -0,0 +1,3 @@ +cargo:rerun-if-changed=build.rs +cargo:rustc-check-cfg=cfg(no_literal_fromstr) +cargo:rustc-check-cfg=cfg(feature, values("protocol_feature_paste")) diff --git a/docs/debug/build/paste-5e5c6d03f89d0c51/root-output b/docs/debug/build/paste-5e5c6d03f89d0c51/root-output new file mode 100644 index 0000000..5f65ed9 --- /dev/null +++ b/docs/debug/build/paste-5e5c6d03f89d0c51/root-output @@ -0,0 +1 @@ +/home/runner/work/ubits/ubits/docs/debug/build/paste-5e5c6d03f89d0c51/out \ No newline at end of file diff --git a/docs/debug/build/paste-5e5c6d03f89d0c51/stderr b/docs/debug/build/paste-5e5c6d03f89d0c51/stderr new file mode 100644 index 0000000..e69de29 diff --git a/docs/debug/deps/doc_comment-bda2383960759dfa.d b/docs/debug/deps/doc_comment-bda2383960759dfa.d deleted file mode 100644 index 18aff55..0000000 --- a/docs/debug/deps/doc_comment-bda2383960759dfa.d +++ /dev/null @@ -1,5 +0,0 @@ -/home/runner/work/ubits/ubits/docs/debug/deps/doc_comment-bda2383960759dfa.rmeta: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/doc-comment-0.3.3/src/lib.rs - -/home/runner/work/ubits/ubits/docs/debug/deps/doc_comment-bda2383960759dfa.d: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/doc-comment-0.3.3/src/lib.rs - -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/doc-comment-0.3.3/src/lib.rs: diff --git a/docs/debug/deps/doc_comment-db0e63784ee930b3.d b/docs/debug/deps/doc_comment-db0e63784ee930b3.d new file mode 100644 index 0000000..b7258d5 --- /dev/null +++ b/docs/debug/deps/doc_comment-db0e63784ee930b3.d @@ -0,0 +1,5 @@ +/home/runner/work/ubits/ubits/docs/debug/deps/doc_comment-db0e63784ee930b3.d: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/doc-comment-0.3.4/src/lib.rs + +/home/runner/work/ubits/ubits/docs/debug/deps/libdoc_comment-db0e63784ee930b3.rmeta: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/doc-comment-0.3.4/src/lib.rs + +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/doc-comment-0.3.4/src/lib.rs: diff --git a/docs/debug/deps/libdoc_comment-bda2383960759dfa.rmeta b/docs/debug/deps/libdoc_comment-bda2383960759dfa.rmeta deleted file mode 100644 index 8db8898..0000000 Binary files a/docs/debug/deps/libdoc_comment-bda2383960759dfa.rmeta and /dev/null differ diff --git a/docs/debug/deps/libdoc_comment-db0e63784ee930b3.rmeta b/docs/debug/deps/libdoc_comment-db0e63784ee930b3.rmeta new file mode 100644 index 0000000..826f3b7 Binary files /dev/null and b/docs/debug/deps/libdoc_comment-db0e63784ee930b3.rmeta differ diff --git a/docs/debug/deps/libpaste-20ebc6fd9e2b3438.so b/docs/debug/deps/libpaste-20ebc6fd9e2b3438.so deleted file mode 100755 index 9174acb..0000000 Binary files a/docs/debug/deps/libpaste-20ebc6fd9e2b3438.so and /dev/null differ diff --git a/docs/debug/deps/libpaste-45ae09343cbe966a.so b/docs/debug/deps/libpaste-45ae09343cbe966a.so new file mode 100755 index 0000000..841f36a Binary files /dev/null and b/docs/debug/deps/libpaste-45ae09343cbe966a.so differ diff --git a/docs/debug/deps/libsafe_transmute-08de2e97acce0a0b.rmeta b/docs/debug/deps/libsafe_transmute-08de2e97acce0a0b.rmeta deleted file mode 100644 index 7d977c9..0000000 Binary files a/docs/debug/deps/libsafe_transmute-08de2e97acce0a0b.rmeta and /dev/null differ diff --git a/docs/debug/deps/libsafe_transmute-323d820241496e09.rmeta b/docs/debug/deps/libsafe_transmute-323d820241496e09.rmeta new file mode 100644 index 0000000..52cea89 Binary files /dev/null and b/docs/debug/deps/libsafe_transmute-323d820241496e09.rmeta differ diff --git a/docs/debug/deps/paste-20ebc6fd9e2b3438.d b/docs/debug/deps/paste-20ebc6fd9e2b3438.d deleted file mode 100644 index a09ff59..0000000 --- a/docs/debug/deps/paste-20ebc6fd9e2b3438.d +++ /dev/null @@ -1,8 +0,0 @@ -/home/runner/work/ubits/ubits/docs/debug/deps/libpaste-20ebc6fd9e2b3438.so: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/lib.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/attr.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/error.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/segment.rs - -/home/runner/work/ubits/ubits/docs/debug/deps/paste-20ebc6fd9e2b3438.d: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/lib.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/attr.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/error.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/segment.rs - -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/lib.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/attr.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/error.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/paste-1.0.7/src/segment.rs: diff --git a/docs/debug/deps/paste-45ae09343cbe966a.d b/docs/debug/deps/paste-45ae09343cbe966a.d new file mode 100644 index 0000000..492c663 --- /dev/null +++ b/docs/debug/deps/paste-45ae09343cbe966a.d @@ -0,0 +1,8 @@ +/home/runner/work/ubits/ubits/docs/debug/deps/paste-45ae09343cbe966a.d: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/lib.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/attr.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/error.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/segment.rs + +/home/runner/work/ubits/ubits/docs/debug/deps/libpaste-45ae09343cbe966a.so: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/lib.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/attr.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/error.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/segment.rs + +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/lib.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/attr.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/error.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/paste-1.0.15/src/segment.rs: diff --git a/docs/debug/deps/safe_transmute-08de2e97acce0a0b.d b/docs/debug/deps/safe_transmute-08de2e97acce0a0b.d deleted file mode 100644 index 5850e3c..0000000 --- a/docs/debug/deps/safe_transmute-08de2e97acce0a0b.d +++ /dev/null @@ -1,16 +0,0 @@ -/home/runner/work/ubits/ubits/docs/debug/deps/safe_transmute-08de2e97acce0a0b.rmeta: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/lib.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/full.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/base.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/bool.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/util.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/align.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/error.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/guard.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/trivial.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/to_bytes.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/migration/mod.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/migration/v0_11.rs - -/home/runner/work/ubits/ubits/docs/debug/deps/safe_transmute-08de2e97acce0a0b.d: /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/lib.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/full.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/base.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/bool.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/util.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/align.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/error.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/guard.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/trivial.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/to_bytes.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/migration/mod.rs /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/migration/v0_11.rs - -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/lib.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/full.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/base.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/bool.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/util.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/align.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/error.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/guard.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/trivial.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/to_bytes.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/migration/mod.rs: -/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/safe-transmute-0.11.2/src/migration/v0_11.rs: diff --git a/docs/debug/deps/safe_transmute-323d820241496e09.d b/docs/debug/deps/safe_transmute-323d820241496e09.d new file mode 100644 index 0000000..99f3a6a --- /dev/null +++ b/docs/debug/deps/safe_transmute-323d820241496e09.d @@ -0,0 +1,16 @@ +/home/runner/work/ubits/ubits/docs/debug/deps/safe_transmute-323d820241496e09.d: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/lib.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/full.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/base.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/bool.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/util.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/align.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/error.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/guard.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/trivial.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/to_bytes.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/migration/mod.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/migration/v0_11.rs + +/home/runner/work/ubits/ubits/docs/debug/deps/libsafe_transmute-323d820241496e09.rmeta: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/lib.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/full.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/base.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/bool.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/util.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/align.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/error.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/guard.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/trivial.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/to_bytes.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/migration/mod.rs /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/migration/v0_11.rs + +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/lib.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/full.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/base.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/bool.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/util.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/align.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/error.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/guard.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/trivial.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/to_bytes.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/migration/mod.rs: +/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/safe-transmute-0.11.3/src/migration/v0_11.rs: diff --git a/docs/doc/.lock b/docs/doc/.lock old mode 100755 new mode 100644 diff --git a/docs/doc/FiraSans-Medium.woff b/docs/doc/FiraSans-Medium.woff deleted file mode 100644 index 7d742c5..0000000 Binary files a/docs/doc/FiraSans-Medium.woff and /dev/null differ diff --git a/docs/doc/FiraSans-Regular.woff b/docs/doc/FiraSans-Regular.woff deleted file mode 100644 index d8e0363..0000000 Binary files a/docs/doc/FiraSans-Regular.woff and /dev/null differ diff --git a/docs/doc/NanumBarunGothic.ttf.woff b/docs/doc/NanumBarunGothic.ttf.woff deleted file mode 100644 index fb063e8..0000000 Binary files a/docs/doc/NanumBarunGothic.ttf.woff and /dev/null differ diff --git a/docs/doc/SourceCodePro-It.ttf.woff b/docs/doc/SourceCodePro-It.ttf.woff deleted file mode 100644 index 8d68f2f..0000000 Binary files a/docs/doc/SourceCodePro-It.ttf.woff and /dev/null differ diff --git a/docs/doc/SourceCodePro-Regular.ttf.woff b/docs/doc/SourceCodePro-Regular.ttf.woff deleted file mode 100644 index 7be076e..0000000 Binary files a/docs/doc/SourceCodePro-Regular.ttf.woff and /dev/null differ diff --git a/docs/doc/SourceCodePro-Semibold.ttf.woff b/docs/doc/SourceCodePro-Semibold.ttf.woff deleted file mode 100644 index 61bc67b..0000000 Binary files a/docs/doc/SourceCodePro-Semibold.ttf.woff and /dev/null differ diff --git a/docs/doc/SourceSerif4-Bold.ttf.woff b/docs/doc/SourceSerif4-Bold.ttf.woff deleted file mode 100644 index 8ad4188..0000000 Binary files a/docs/doc/SourceSerif4-Bold.ttf.woff and /dev/null differ diff --git a/docs/doc/SourceSerif4-Bold.ttf.woff2 b/docs/doc/SourceSerif4-Bold.ttf.woff2 deleted file mode 100644 index db57d21..0000000 Binary files a/docs/doc/SourceSerif4-Bold.ttf.woff2 and /dev/null differ diff --git a/docs/doc/SourceSerif4-It.ttf.woff b/docs/doc/SourceSerif4-It.ttf.woff deleted file mode 100644 index 2a34b5c..0000000 Binary files a/docs/doc/SourceSerif4-It.ttf.woff and /dev/null differ diff --git a/docs/doc/SourceSerif4-It.ttf.woff2 b/docs/doc/SourceSerif4-It.ttf.woff2 deleted file mode 100644 index 1cbc021..0000000 Binary files a/docs/doc/SourceSerif4-It.ttf.woff2 and /dev/null differ diff --git a/docs/doc/SourceSerif4-Regular.ttf.woff b/docs/doc/SourceSerif4-Regular.ttf.woff deleted file mode 100644 index 45a5521..0000000 Binary files a/docs/doc/SourceSerif4-Regular.ttf.woff and /dev/null differ diff --git a/docs/doc/SourceSerif4-Regular.ttf.woff2 b/docs/doc/SourceSerif4-Regular.ttf.woff2 deleted file mode 100644 index 2db73fe..0000000 Binary files a/docs/doc/SourceSerif4-Regular.ttf.woff2 and /dev/null differ diff --git a/docs/doc/ayu.css b/docs/doc/ayu.css deleted file mode 100644 index 50d893e..0000000 --- a/docs/doc/ayu.css +++ /dev/null @@ -1 +0,0 @@ - body{background-color:#0f1419;color:#c5c5c5;}h1,h2,h3,h4{color:white;}h1.fqn{border-bottom-color:#5c6773;}h1.fqn a{color:#fff;}h2,h3,h4{border-bottom-color:#5c6773;}h4{border:none;}.in-band{background-color:#0f1419;}.invisible{background:rgba(0,0,0,0);}.docblock code{color:#ffb454;}.code-header{color:#e6e1cf;}.docblock pre>code,pre>code{color:#e6e1cf;}span code{color:#e6e1cf;}.docblock a>code{color:#39AFD7 !important;}.docblock code,.docblock-short code{background-color:#191f26;}pre,.rustdoc.source .example-wrap{color:#e6e1cf;background-color:#191f26;}.sidebar,.mobile-topbar,.sidebar-menu-toggle{background-color:#14191f;}.rust-logo{filter:drop-shadow(1px 0 0px #fff) drop-shadow(0 1px 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 -1px 0 #fff);}*{scrollbar-color:#5c6773 #24292f;}.sidebar{scrollbar-color:#5c6773 #24292f;}::-webkit-scrollbar-track{background-color:transparent;}::-webkit-scrollbar-thumb{background-color:#5c6773;}.sidebar::-webkit-scrollbar-track{background-color:transparent;}.sidebar::-webkit-scrollbar-thumb{background-color:#5c6773;}.sidebar .current,.sidebar a:hover{background-color:transparent;color:#ffb44c;}.source .sidebar{background-color:#14191f;}.sidebar-elems .location{color:#ff7733;}.line-numbers span{color:#5c6773;}.line-numbers .line-highlighted{color:#708090;background-color:rgba(255,236,164,0.06);padding-right:4px;border-right:1px solid #ffb44c;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5,.docblock h6{border-bottom-color:#5c6773;}.docblock table td,.docblock table th{border-color:#5c6773;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#c5c5c5;}.search-results a:hover{background-color:#777;}.search-results a:focus{color:#000 !important;background-color:#c6afb3;}.search-results a{color:#0096cf;}.search-results a div.desc{color:#c5c5c5;}.content .item-info::before{color:#ccc;}.content span.foreigntype,.content a.foreigntype{color:#ffa0a5;}.content span.union,.content a.union{color:#ffa0a5;}.content span.constant,.content a.constant,.content span.static,.content a.static{color:#39AFD7;}.content span.primitive,.content a.primitive{color:#ffa0a5;}.content span.traitalias,.content a.traitalias{color:#39AFD7;}.content span.keyword,.content a.keyword{color:#39AFD7;}.content span.externcrate,.content span.mod,.content a.mod{color:#39AFD7;}.content span.struct,.content a.struct{color:#ffa0a5;}.content span.enum,.content a.enum{color:#ffa0a5;}.content span.trait,.content a.trait{color:#39AFD7;}.content span.type,.content a.type{color:#39AFD7;}.content span.type,.content a.type,.block a.current.type{color:#39AFD7;}.content span.associatedtype,.content a.associatedtype,.block a.current.associatedtype{color:#39AFD7;}.content span.fn,.content a.fn,.content span.method,.content a.method,.content span.tymethod,.content a.tymethod,.content .fnname{color:#fdd687;}.content span.attr,.content a.attr,.content span.derive,.content a.derive,.content span.macro,.content a.macro{color:#a37acc;}.sidebar a{color:#53b1db;}.sidebar a.current.type{color:#53b1db;}.sidebar a.current.associatedtype{color:#53b1db;}pre.rust .comment{color:#788797;}pre.rust .doccomment{color:#a1ac88;}nav.main .current{border-top-color:#5c6773;border-bottom-color:#5c6773;}nav.main .separator{border:1px solid #5c6773;}a{color:#39AFD7;}a#toggle-all-docs,a.anchor,.small-section-header a,#source-sidebar a,pre.rust a,.sidebar h2 a,.sidebar h3 a,.mobile-topbar h2 a,.in-band a{color:#c5c5c5;}.sidebar h2 a,.sidebar h3 a{color:white;}.search-results a{color:#0096cf;}body.source .example-wrap pre.rust a{background:#333;}details.rustdoc-toggle>summary.hideme>span,details.rustdoc-toggle>summary::before,details.undocumented>summary::before{color:#999;}details.rustdoc-toggle>summary::before,details.undocumented>summary::before{filter:invert(100%);}#crate-search,.search-input{background-color:#141920;border-color:#424c57;color:#c5c5c5;}.search-input{color:#ffffff;}.module-item .stab,.import-item .stab{color:#000;}.stab.unstable,.stab.deprecated,.stab.portability{color:#c5c5c5;background:#314559 !important;border-style:none !important;border-radius:4px;padding:3px 6px 3px 6px;}.stab.portability>code{color:#e6e1cf;background:none;}#help>div{background:#14191f;box-shadow:0px 6px 20px 0px black;border:none;border-radius:4px;}#help span.bottom,#help span.top{border-color:#5c6773;}.rightside,.out-of-band{color:grey;}.result-name .primitive>i,.result-name .keyword>i{color:#788797;}.line-numbers :target{background-color:transparent;}pre.rust .number,pre.rust .string{color:#b8cc52;}pre.rust .kw,pre.rust .kw-2,pre.rust .prelude-ty,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .op,pre.rust .lifetime{color:#ff7733;}pre.rust .macro,pre.rust .macro-nonterminal{color:#a37acc;}pre.rust .question-mark{color:#ff9011;}pre.rust .self{color:#36a3d9;font-style:italic;}pre.rust .attribute{color:#e6e1cf;}pre.rust .attribute .ident,pre.rust .attribute .op{color:#e6e1cf;}.example-wrap>pre.line-number{color:#5c67736e;border:none;}a.test-arrow{font-size:100%;color:#788797;border-radius:4px;background-color:rgba(57,175,215,0.09);}a.test-arrow:hover{background-color:rgba(57,175,215,0.368);color:#c5c5c5;}.toggle-label,.code-attribute{color:#999;}:target{background:rgba(255,236,164,0.06);border-right:3px solid rgba(255,180,76,0.85);}pre.compile_fail{border-left:2px solid rgba(255,0,0,.4);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.should_panic{border-left:2px solid rgba(255,0,0,.4);}pre.should_panic:hover,.information:hover+pre.should_panic{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.6);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.5);}.information>.compile_fail:hover{color:#f00;}.tooltip.should_panic{color:rgba(255,0,0,.5);}.information>.should_panic:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.6);}.information>.ignore:hover{color:#ff9200;}.search-failed a{color:#39AFD7;}.tooltip::after{background-color:#314559;color:#c5c5c5;border:1px solid #5c6773;}.tooltip::before{border-color:transparent #314559 transparent transparent;}.notable-traits-tooltiptext{background-color:#314559;border-color:#5c6773;}.notable-traits-tooltiptext .notable{border-bottom-color:#5c6773;}#titles>button.selected{background-color:#141920 !important;border-bottom:1px solid #ffb44c !important;border-top:none;}#titles>button:not(.selected){background-color:transparent !important;border:none;}#titles>button:hover{border-bottom:1px solid rgba(242,151,24,0.3);}#titles>button>div.count{color:#888;}.search-input:focus{}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{}.content span.struct,.content a.struct,.block a.current.struct{}#titles>button:hover,#titles>button.selected{}.content span.typedef,.content a.typedef,.block a.current.typedef{}.content span.union,.content a.union,.block a.current.union{}pre.rust .lifetime{}.stab.unstable{}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){}.content span.enum,.content a.enum,.block a.current.enum{}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{}.content span.keyword,.content a.keyword,.block a.current.keyword{}pre.rust .comment{}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{}pre.rust .kw{}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{}pre.rust .doccomment{}.stab.deprecated{}.content a.attr,.content a.derive,.content a.macro{}.stab.portability{}.content span.primitive,.content a.primitive,.block a.current.primitive{}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{}pre.rust .kw-2,pre.rust .prelude-ty{}.content span.trait,.content a.trait,.block a.current.trait{}.search-results a:focus span{}a.result-trait:focus{}a.result-traitalias:focus{}a.result-mod:focus,a.result-externcrate:focus{}a.result-mod:focus{}a.result-externcrate:focus{}a.result-enum:focus{}a.result-struct:focus{}a.result-union:focus{}a.result-fn:focus,a.result-method:focus,a.result-tymethod:focus{}a.result-type:focus{}a.result-associatedtype:focus{}a.result-foreigntype:focus{}a.result-attr:focus,a.result-derive:focus,a.result-macro:focus{}a.result-constant:focus,a.result-static:focus{}a.result-primitive:focus{}a.result-keyword:focus{}.sidebar a.current.enum{}.sidebar a.current.struct{}.sidebar a.current.foreigntype{}.sidebar a.current.attr,.sidebar a.current.derive,.sidebar a.current.macro{}.sidebar a.current.union{}.sidebar a.current.constant .sidebar a.current.static{}.sidebar a.current.primitive{}.sidebar a.current.externcrate .sidebar a.current.mod{}.sidebar a.current.trait{}.sidebar a.current.traitalias{}.sidebar a.current.fn,.sidebar a.current.method,.sidebar a.current.tymethod{}.sidebar a.current.keyword{}@media (max-width:700px){.sidebar-menu{background-color:#14191f;border-bottom-color:#5c6773;border-right-color:#5c6773;}.sidebar-elems{background-color:#14191f;border-right-color:#5c6773;}#sidebar-filler{background-color:#14191f;border-bottom-color:#5c6773;}}kbd{color:#c5c5c5;background-color:#314559;border-color:#5c6773;border-bottom-color:#5c6773;box-shadow:inset 0 -1px 0 #5c6773;}#theme-picker,#settings-menu,#help-button{border-color:#5c6773;background-color:#0f1419;color:#fff;}#theme-picker>img,#settings-menu>img{filter:invert(100);}#copy-path{color:#fff;}#copy-path>img{filter:invert(70%);}#copy-path:hover>img{filter:invert(100%);}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus,#help-button:hover,#help-button:focus{border-color:#e0e0e0;}#theme-choices{border-color:#5c6773;background-color:#0f1419;}#theme-choices>button:not(:first-child){border-top-color:#5c6773;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:rgba(110,110,110,0.33);}@media (max-width:700px){#theme-picker{background:#0f1419;}}.search-results .result-name span.alias{color:#c5c5c5;}.search-results .result-name span.grey{color:#999;}#sidebar-toggle{background-color:#14191f;}#sidebar-toggle:hover{background-color:rgba(70,70,70,0.33);}#source-sidebar{background-color:#14191f;}#source-sidebar>.title{color:#fff;border-bottom-color:#5c6773;}div.files>a:hover,div.name:hover{background-color:#14191f;color:#ffb44c;}div.files>.selected{background-color:#14191f;color:#ffb44c;}.setting-line>.title{border-bottom-color:#5c6773;}input:checked+.slider{background-color:#ffb454 !important;}.scraped-example .example-wrap .rust span.highlight{background:rgb(91,59,1);}.scraped-example .example-wrap .rust span.highlight.focus{background:rgb(124,75,15);}.scraped-example:not(.expanded) .code-wrapper:before{background:linear-gradient(to bottom,rgba(15,20,25,1),rgba(15,20,25,0));}.scraped-example:not(.expanded) .code-wrapper:after{background:linear-gradient(to top,rgba(15,20,25,1),rgba(15,20,25,0));}.toggle-line-inner{background:#616161;}.toggle-line:hover .toggle-line-inner{background:#898989;} \ No newline at end of file diff --git a/docs/doc/brush.svg b/docs/doc/brush.svg deleted file mode 100644 index ea266e8..0000000 --- a/docs/doc/brush.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/docs/doc/clipboard.svg b/docs/doc/clipboard.svg deleted file mode 100644 index 8adbd99..0000000 --- a/docs/doc/clipboard.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docs/doc/crates.js b/docs/doc/crates.js index b86dfd5..b6797bc 100644 --- a/docs/doc/crates.js +++ b/docs/doc/crates.js @@ -1 +1,2 @@ -window.ALL_CRATES = ["ubits"]; \ No newline at end of file +window.ALL_CRATES = ["ubits"]; +//{"start":21,"fragment_lengths":[7]} \ No newline at end of file diff --git a/docs/doc/dark.css b/docs/doc/dark.css deleted file mode 100644 index a31f453..0000000 --- a/docs/doc/dark.css +++ /dev/null @@ -1 +0,0 @@ -body{background-color:#353535;color:#ddd;}h1,h2,h3,h4{color:#ddd;}h1.fqn{border-bottom-color:#d2d2d2;}h2,h3,h4{border-bottom-color:#d2d2d2;}.in-band{background-color:#353535;}.invisible{background:rgba(0,0,0,0);}.docblock code,.docblock-short code{background-color:#2A2A2A;}pre,.rustdoc.source .example-wrap{background-color:#2A2A2A;}.sidebar,.mobile-topbar,.sidebar-menu-toggle{background-color:#505050;}.rust-logo{filter:drop-shadow(1px 0 0px #fff) drop-shadow(0 1px 0 #fff) drop-shadow(-1px 0 0 #fff) drop-shadow(0 -1px 0 #fff)}*{scrollbar-color:rgb(64,65,67) #717171;}.sidebar{scrollbar-color:rgba(32,34,37,.6) #5a5a5a;}::-webkit-scrollbar-track{background-color:#717171;}::-webkit-scrollbar-thumb{background-color:rgba(32,34,37,.6);}.sidebar::-webkit-scrollbar-track{background-color:#717171;}.sidebar::-webkit-scrollbar-thumb{background-color:rgba(32,34,37,.6);}.sidebar .current,.sidebar a:hover{background:#444;}.source .sidebar{background-color:#565656;}.line-numbers span{color:#3B91E2;}.line-numbers .line-highlighted{background-color:#0a042f !important;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5,.docblock h6{border-bottom-color:#DDD;}.docblock table td,.docblock table th{border-color:#ddd;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#ddd;}.search-results a:hover{background-color:#777;}.search-results a:focus{color:#eee !important;background-color:#616161;}.search-results a:focus span{color:#eee !important;}a.result-trait:focus{background-color:#013191;}a.result-traitalias:focus{background-color:#013191;}a.result-mod:focus,a.result-externcrate:focus{background-color:#884719;}a.result-enum:focus{background-color:#194e9f;}a.result-struct:focus{background-color:#194e9f;}a.result-union:focus{background-color:#194e9f;}a.result-fn:focus,a.result-method:focus,a.result-tymethod:focus{background-color:#4950ed;}a.result-type:focus{background-color:#194e9f;}a.result-associatedtype:focus{background-color:#884719;}a.result-foreigntype:focus{background-color:#194e9f;}a.result-attr:focus,a.result-derive:focus,a.result-macro:focus{background-color:#217d1c;}a.result-constant:focus,a.result-static:focus{background-color:#884719;}a.result-primitive:focus{background-color:#194e9f;}a.result-keyword:focus{background-color:#884719;}.content .item-info::before{color:#ccc;}.content span.enum,.content a.enum,.block a.current.enum{color:#2dbfb8;}.content span.struct,.content a.struct,.block a.current.struct{color:#2dbfb8;}.content span.type,.content a.type,.block a.current.type{color:#2dbfb8;}.content span.associatedtype,.content a.associatedtype,.block a.current.associatedtype{color:#D2991D;}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{color:#2dbfb8;}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{color:#09bd00;}.content span.union,.content a.union,.block a.current.union{color:#2dbfb8;}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{color:#D2991D;}.content span.primitive,.content a.primitive,.block a.current.primitive{color:#2dbfb8;}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{color:#D2991D;}.content span.trait,.content a.trait,.block a.current.trait{color:#b78cf2;}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{color:#b78cf2;}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{color:#2BAB63;}.content span.keyword,.content a.keyword,.block a.current.keyword{color:#D2991D;}.sidebar a{color:#fdbf35;}.sidebar a.current.enum{color:#12ece2;}.sidebar a.current.struct{color:#12ece2;}.sidebar a.current.type{color:#12ece2;}.sidebar a.current.associatedtype{color:#fdbf35;}.sidebar a.current.foreigntype{color:#12ece2;}.sidebar a.current.attr,.sidebar a.current.derive,.sidebar a.current.macro{color:#0be900;}.sidebar a.current.union{color:#12ece2;}.sidebar a.current.constant .sidebar a.current.static{color:#fdbf35;}.sidebar a.current.primitive{color:#12ece2;}.sidebar a.current.externcrate .sidebar a.current.mod{color:#fdbf35;}.sidebar a.current.trait{color:#cca7ff;}.sidebar a.current.traitalias{color:#cca7ff;}.sidebar a.current.fn,.sidebar a.current.method,.sidebar a.current.tymethod{color:#32d479;}.sidebar a.current.keyword{color:#fdbf35;}pre.rust .comment{color:#8d8d8b;}pre.rust .doccomment{color:#8ca375;}nav.main .current{border-top-color:#eee;border-bottom-color:#eee;}nav.main .separator{border-color:#eee;}a{color:#D2991D;}a#toggle-all-docs,a.anchor,.small-section-header a,#source-sidebar a,pre.rust a,.sidebar h2 a,.sidebar h3 a,.mobile-topbar h2 a,.in-band a{color:#ddd;}.search-results a{color:#ddd;}a.test-arrow{color:#dedede;}body.source .example-wrap pre.rust a{background:#333;}details.rustdoc-toggle>summary.hideme>span,details.rustdoc-toggle>summary::before,details.undocumented>summary::before{color:#999;}details.rustdoc-toggle>summary::before,details.undocumented>summary::before{filter:invert(100%);}#crate-search,.search-input{color:#111;background-color:#f0f0f0;border-color:#000;}.search-input{border-color:#e0e0e0;}.search-input:focus{border-color:#008dfd;}.module-item .stab,.import-item .stab{color:#ddd;}.stab.unstable{background:#FFF5D6;border-color:#FFC600;color:#2f2f2f;}.stab.deprecated{background:#ffc4c4;border-color:#db7b7b;color:#2f2f2f;}.stab.portability{background:#F3DFFF;border-color:#b07bdb;color:#2f2f2f;}.stab.portability>code{background:none;}#help>div{background:#4d4d4d;border-color:#bfbfbf;}#help span.bottom,#help span.top{border-color:#bfbfbf;}#help dt{border-color:#bfbfbf;background:rgba(0,0,0,0);}.rightside,.out-of-band{color:grey;}.result-name .primitive>i,.result-name .keyword>i{color:#ddd;}.line-numbers :target{background-color:transparent;}pre.rust .kw{color:#ab8ac1;}pre.rust .kw-2,pre.rust .prelude-ty{color:#769acb;}pre.rust .number,pre.rust .string{color:#83a300;}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{color:#ee6868;}pre.rust .macro,pre.rust .macro-nonterminal{color:#3E999F;}pre.rust .lifetime{color:#d97f26;}pre.rust .question-mark{color:#ff9011;}.example-wrap>pre.line-number{border-color:#4a4949;}a.test-arrow{background-color:rgba(78,139,202,0.2);}a.test-arrow:hover{background-color:#4e8bca;}.toggle-label,.code-attribute{color:#999;}:target{background-color:#494a3d;border-right:3px solid #bb7410;}pre.compile_fail{border-left:2px solid rgba(255,0,0,.8);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.should_panic{border-left:2px solid rgba(255,0,0,.8);}pre.should_panic:hover,.information:hover+pre.should_panic{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.6);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.8);}.information>.compile_fail:hover{color:#f00;}.tooltip.should_panic{color:rgba(255,0,0,.8);}.information>.should_panic:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.6);}.information>.ignore:hover{color:#ff9200;}.search-failed a{color:#0089ff;}.tooltip::after{background-color:#000;color:#fff;border-color:#000;}.tooltip::before{border-color:transparent black transparent transparent;}.notable-traits-tooltiptext{background-color:#111;border-color:#777;}.notable-traits-tooltiptext .notable{border-bottom-color:#d2d2d2;}#titles>button:not(.selected){background-color:#252525;border-top-color:#252525;}#titles>button:hover,#titles>button.selected{border-top-color:#0089ff;background-color:#353535;}#titles>button>div.count{color:#888;}@media (max-width:700px){.sidebar-menu{background-color:#505050;border-bottom-color:#e0e0e0;border-right-color:#e0e0e0;}.sidebar-elems{background-color:#505050;border-right-color:#000;}#sidebar-filler{background-color:#505050;border-bottom-color:#e0e0e0;}}kbd{color:#000;background-color:#fafbfc;border-color:#d1d5da;border-bottom-color:#c6cbd1;box-shadow:inset 0 -1px 0 #c6cbd1;}#theme-picker,#settings-menu,#help-button{border-color:#e0e0e0;background:#f0f0f0;color:#000;}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus,#help-button:hover,#help-button:focus{border-color:#ffb900;}#copy-path{color:#999;}#copy-path>img{filter:invert(50%);}#copy-path:hover>img{filter:invert(65%);}#theme-choices{border-color:#e0e0e0;background-color:#353535;}#theme-choices>button:not(:first-child){border-top-color:#e0e0e0;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:#4e4e4e;}@media (max-width:700px){#theme-picker{background:#f0f0f0;}}.search-results .result-name span.alias{color:#fff;}.search-results .result-name span.grey{color:#ccc;}#sidebar-toggle{background-color:#565656;}#sidebar-toggle:hover{background-color:#676767;}#source-sidebar{background-color:#565656;}#source-sidebar>.title{border-bottom-color:#ccc;}div.files>a:hover,div.name:hover{background-color:#444;}div.files>.selected{background-color:#333;}.setting-line>.title{border-bottom-color:#ddd;}.scraped-example .example-wrap .rust span.highlight{background:rgb(91,59,1);}.scraped-example .example-wrap .rust span.highlight.focus{background:rgb(124,75,15);}.scraped-example:not(.expanded) .code-wrapper:before{background:linear-gradient(to bottom,rgba(53,53,53,1),rgba(53,53,53,0));}.scraped-example:not(.expanded) .code-wrapper:after{background:linear-gradient(to top,rgba(53,53,53,1),rgba(53,53,53,0));}.toggle-line-inner{background:#616161;}.toggle-line:hover .toggle-line-inner{background:#898989;} \ No newline at end of file diff --git a/docs/doc/down-arrow.svg b/docs/doc/down-arrow.svg deleted file mode 100644 index 35437e7..0000000 --- a/docs/doc/down-arrow.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/docs/doc/favicon-16x16.png b/docs/doc/favicon-16x16.png deleted file mode 100644 index ea4b45c..0000000 Binary files a/docs/doc/favicon-16x16.png and /dev/null differ diff --git a/docs/doc/favicon-32x32.png b/docs/doc/favicon-32x32.png deleted file mode 100644 index 69b8613..0000000 Binary files a/docs/doc/favicon-32x32.png and /dev/null differ diff --git a/docs/doc/help.html b/docs/doc/help.html new file mode 100644 index 0000000..e3d3af6 --- /dev/null +++ b/docs/doc/help.html @@ -0,0 +1 @@ +
fn:) to \
- restrict the search to a given item kind.","Accepted kinds are: fn, mod, struct, \
- enum, trait, type, macro, \
- and const.","Search functions by type signature (e.g., vec -> usize or \
- * -> vec)","Search multiple things at once by splitting your query with comma (e.g., \
- str,u8 or String,struct:Vec,test)","You can look for items with an exact name by putting double quotes around \
- your request: \"string\"","Look for items inside another one by searching for a path: vec::Vec",].map(function(x){return""+x+"
"}).join("");var div_infos=document.createElement("div");addClass(div_infos,"infos");div_infos.innerHTML="ExampleField.","Number of bytes used by an instance of ExampleField.","Optional docstring for my example bit field.","Maximum valid integer for ExampleField.","Returns the current field value as a binary formatted …","Returns the current field value as a u8","","","","","","","","","Sets the value of the bit at the supplied index to 0.","","","Returns a new ExampleFieldwith ones for flags that were …","","Returns a new ExampleFieldwith ones for flags that do not …","","","","Returns the argument unchanged.","","Create a new instance of ExampleField from a binary string.","Create a new instance of ExampleField from a binary string.","Returns the value of the bit at the supplied index as a …","Returns a new ExampleFieldwith ones for flags that were …","Calls U::from(self).","Returns a new ExampleFieldwith ones for flags that were …","Returns a new ExampleFieldwith ones for flags that do not …","Returns a new ExampleFieldwith ones for flags that were …","","Create a new instance of ExampleField from a u8 value.","Create a new instance of ExampleField from the maximum …","","Sets the value of the bit at the supplied index to 1.","","Flips the value of the bit at the supplied index.","","","","Create a new instance of ExampleField from 0.","Number of bits in an instance of ExampleField.","Number of bytes used by an instance of ExampleField.","Optional docstring for my example bit field.","Optional docstring for my flag enum.","Optional docstring for Flag0","Optional docstring for Flag1","Optional docstring for Flag2","Optional docstring for Flag3","Optional docstring for Flag4","Optional docstring for Flag5","Optional docstring for Flag6","Optional docstring for Flag7","Maximum valid integer for ExampleField.","Returns the current field value as a binary formatted …","Returns the current field value as a u8","","","","","","","","","","","","","","","","","","","","Sets the value of the bit at the supplied flag to 0.","Sets the value of the bit at the supplied index to 0.","","","","","Returns a new ExampleFieldwith ones for flags that were …","","Returns a new ExampleFieldwith ones for flags that do not …","","","","","","","Returns the argument unchanged.","","","Returns the argument unchanged.","Create a new instance of ExampleField from a binary string.","Create a new instance of ExampleField from a binary string.","Returns the value of the bit at the supplied flag as a …","Returns the value of the bit at the supplied index as a …","Returns a new ExampleFieldwith ones for flags that were …","Calls U::from(self).","Calls U::from(self).","Returns a new ExampleFieldwith ones for flags that were …","Returns a new ExampleFieldwith ones for flags that do not …","Returns a new ExampleFieldwith ones for flags that were …","","Create a new instance of ExampleField from a u8 value.","Create a new instance of ExampleField from the maximum …","","","Sets the value of the bit at the supplied flag to 1.","Sets the value of the bit at the supplied index to 1.","","","Flips the value of the bit at the supplied flag.","Flips the value of the bit at the supplied index.","","","","","","","Create a new instance of ExampleField from 0."],"i":[0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,0,0,3,3,3,3,3,3,3,3,2,2,2,3,2,2,2,2,3,2,2,2,2,3,2,2,2,2,3,2,3,2,2,2,3,2,3,2,2,2,2,3,2,3,2,2,3,3,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,3,2,2,2,3,2,2,2,3,2,3,2,3,2,2],"f":[null,null,null,null,null,null,null,null,[[["",0]],["string",3]],[[["",0]],["u8",0]],[[]],[[["",0]]],[[]],[[["",0]]],[[]],[[["",0]]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0],["u8",0]]],[[["",0]],["examplefield",3]],[[["",0],["",0]]],[[["",0]]],[[]],[[["",0]]],[[["",0],["examplefield",3]],["bool",0]],[[["",0],["formatter",3]],["result",6]],[[["",0],["formatter",3]],["result",6]],[[]],[[["u8",0]],["examplefield",3]],[[["str",0]]],[[["string",3]]],[[["",0],["u8",0]],["bool",0]],[[["",0]]],[[]],[[]],[[]],[[]],[[["",0],["examplefield",3]],["bool",0]],[[["u8",0]]],[[]],[[["",0],["examplefield",3]],["option",4,[["ordering",4]]]],[[["",0],["u8",0]]],[[["",0]]],[[["",0],["u8",0]]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[]],null,null,null,null,null,null,null,null,null,null,null,null,null,[[["",0]],["string",3]],[[["",0]],["u8",0]],[[]],[[["exampleflags",4]]],[[]],[[["",0],["exampleflags",4]]],[[["",0]]],[[]],[[]],[[["exampleflags",4]]],[[["",0],["exampleflags",4]]],[[["",0]]],[[]],[[["exampleflags",4]]],[[]],[[["",0],["exampleflags",4]]],[[["",0]]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0],["exampleflags",4]],["",0]],[[["",0],["u8",0]]],[[["",0]],["exampleflags",4]],[[["",0]],["examplefield",3]],[[["",0],["",0]]],[[["",0],["",0]]],[[["",0]]],[[]],[[["",0]]],[[["",0],["exampleflags",4]],["bool",0]],[[["",0],["examplefield",3]],["bool",0]],[[["",0],["formatter",3]],["result",6]],[[["",0],["formatter",3]],["result",6]],[[["",0],["formatter",3]],["result",6]],[[["u8",0]],["exampleflags",4]],[[]],[[["u8",0]],["examplefield",3]],[[["exampleflags",4]],["examplefield",3]],[[]],[[["str",0]]],[[["string",3]]],[[["",0],["exampleflags",4]],["bool",0]],[[["",0],["u8",0]],["bool",0]],[[["",0]]],[[]],[[]],[[]],[[]],[[]],[[["",0],["examplefield",3]],["bool",0]],[[["u8",0]]],[[]],[[["",0],["exampleflags",4]],["option",4,[["ordering",4]]]],[[["",0],["examplefield",3]],["option",4,[["ordering",4]]]],[[["",0],["exampleflags",4]],["",0]],[[["",0],["u8",0]]],[[["",0]]],[[["",0]]],[[["",0],["exampleflags",4]],["",0]],[[["",0],["u8",0]]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],[[]]],"p":[[3,"ExampleField"],[3,"ExampleField"],[4,"ExampleFlags"]]}\
-}');
-if (window.initSearch) {window.initSearch(searchIndex)};
\ No newline at end of file
diff --git a/docs/doc/search.index/0a32bd316874.js b/docs/doc/search.index/0a32bd316874.js
new file mode 100644
index 0000000..ed42756
--- /dev/null
+++ b/docs/doc/search.index/0a32bd316874.js
@@ -0,0 +1 @@
+rn_("MUAAADwAPQBSAFMAJQFCAAAjdgB3AHgAJ5AAkQCSAGl0NQA2ADcAFQBAAAAXlQCWAHNaAFsABQHAAAATfgB/AAOAAGlsBQBBAAAUeQB6AGk0ALcAAIWwQACGAAGwUACEAAEhASL1TwAAADUAAQAQAAEAIUIAAHsAfAB9AAUJwQAAACYAACcAACgAACkAACoAACsAACwAAC0AGpUAlgAAgAAwMTIzNDU2N2xztwYAh4AAWQJQAbBwAIQAAR1IBAEUAAAA")
\ No newline at end of file
diff --git a/docs/doc/search.index/11bf11a6c640.js b/docs/doc/search.index/11bf11a6c640.js
new file mode 100644
index 0000000..9ad82b8
--- /dev/null
+++ b/docs/doc/search.index/11bf11a6c640.js
@@ -0,0 +1 @@
+rn_("VQBCAAAliwCMAI0AYUYARwBIAEkASgBLAFUAQQAAJYEAggCDAGEuAC8AMAAxADIAMwBVAEIAACWIAIkAigBhQABBAEIAQwBEAEUAVwEAhaBAAAAAWYAAEgAQJSFAIvQjAAAAbQABAAEA")
\ No newline at end of file
diff --git a/docs/doc/search.index/2dcde0157dc7.js b/docs/doc/search.index/2dcde0157dc7.js
new file mode 100644
index 0000000..0163163
--- /dev/null
+++ b/docs/doc/search.index/2dcde0157dc7.js
@@ -0,0 +1 @@
+rn_("JQBAAAAicwB0AHUAbUwATQBOABUASAAAEpkAmgBpkwCUAPMAAWI7MAAAAQAACQACABcABgBfAAIAWwOwAAA5AAFtc3c=")
\ No newline at end of file
diff --git a/docs/doc/search.index/36ba7d91284a.js b/docs/doc/search.index/36ba7d91284a.js
new file mode 100644
index 0000000..1355401
--- /dev/null
+++ b/docs/doc/search.index/36ba7d91284a.js
@@ -0,0 +1 @@
+rn_("VQBBAAAliwCMAI0AYUYARwBIAEkASgBLAAUBwAAAE34AfwADgABpbBMEArAAAFoAAWZz9IQAAAABABAAAQDzAAJhbzowAAABAAAAAAAJABAAAAAFAAYAaABpAG8AcAB5AHoAhgCHAA==")
\ No newline at end of file
diff --git a/docs/doc/search.index/406b87d06b75.js b/docs/doc/search.index/406b87d06b75.js
new file mode 100644
index 0000000..90e6ee0
--- /dev/null
+++ b/docs/doc/search.index/406b87d06b75.js
@@ -0,0 +1 @@
+rn_("FQBCAAASmQCaAGmTAJQAMUMAAD8AVQBWAFcAIUMAAGIAYwBkACFDAABfAGAAYQD3AACFsCAAJAABIIEG8mYAAAABAA==")
\ No newline at end of file
diff --git a/docs/doc/search.index/4fd7c14ef5fd.js b/docs/doc/search.index/4fd7c14ef5fd.js
new file mode 100644
index 0000000..90b4af3
--- /dev/null
+++ b/docs/doc/search.index/4fd7c14ef5fd.js
@@ -0,0 +1 @@
+rn_("hQJAAAAXjgCPABNsAG0AG5cAmABjZGkeAB8AIABiAGMAZAB2AHcAeAAVAEMAABKXAJgAaWoAawDzAAFzAVQAAAArArAgAHEAAWdy+wJlbw==")
\ No newline at end of file
diff --git a/docs/doc/search.index/alias/a762150c532c.js b/docs/doc/search.index/alias/a762150c532c.js
new file mode 100644
index 0000000..f829e46
--- /dev/null
+++ b/docs/doc/search.index/alias/a762150c532c.js
@@ -0,0 +1 @@
+rd_("")
\ No newline at end of file
diff --git a/docs/doc/search.index/crateNames/a54e295c7d06.js b/docs/doc/search.index/crateNames/a54e295c7d06.js
new file mode 100644
index 0000000..3b791ba
--- /dev/null
+++ b/docs/doc/search.index/crateNames/a54e295c7d06.js
@@ -0,0 +1 @@
+rd_("eubits")
\ No newline at end of file
diff --git a/docs/doc/search.index/desc/614df692f6ed.js b/docs/doc/search.index/desc/614df692f6ed.js
new file mode 100644
index 0000000..7b7b091
--- /dev/null
+++ b/docs/doc/search.index/desc/614df692f6ed.js
@@ -0,0 +1 @@
+rd_("CdMaximum valid integer for ExampleField.0CjReturns the value of the bit at the supplied flag as a \xe2\x80\xa6E`Create a new instance of ExampleField from a u8 value.0DaSets the value of the bit at the supplied flag to 1.CkNumber of bits in an instance of ExampleField.0DjReturns a new ExampleFieldwith ones for flags that do not \xe2\x80\xa60AoReturns the argument unchanged.00BaCalls U::from(self).00DgCreate a new instance of ExampleField from the maximum \xe2\x80\xa60DaNumber of bytes used by an instance of ExampleField.0AlOptional docstring for Flag0AlOptional docstring for Flag1AlOptional docstring for Flag2AlOptional docstring for Flag3AlOptional docstring for Flag4AlOptional docstring for Flag5AlOptional docstring for Flag6AlOptional docstring for Flag7DaSets the value of the bit at the supplied flag to 0.Bfcrates.io Downloads Build Docs LicenceDgCreate a new instance of ExampleField from 0.0C`Flips the value of the bit at the supplied flag.DhReturns a new ExampleFieldwith ones for flags that were \xe2\x80\xa60CjGenerates a bitfield struct and a corresponding flag enum.C`Examples of generated output using different \xe2\x80\xa6CiReturns the current field value as a binary formatted \xe2\x80\xa60CkReturns the value of the bit at the supplied index as a \xe2\x80\xa6044DjReturns a new ExampleFieldwith ones for flags that do not \xe2\x80\xa60DbSets the value of the bit at the supplied index to 1.0CdReturns the current field value as a u80DbSets the value of the bit at the supplied index to 0.0BlOptional docstring for my example bit field.0BdOptional docstring for my flag enum.CmExample of generated output, using both a bit field and a \xe2\x80\xa6CaFlips the value of the bit at the supplied index.0<1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 - 48 - 49 - 50 - 51 - 52 - 53 - 54 - 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 - 63 - 64 - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - 74 - 75 - 76 - 77 - 78 - 79 - 80 - 81 - 82 - 83 - 84 - 85 - 86 - 87 - 88 - 89 - 90 - 91 - 92 - 93 - 94 - 95 - 96 - 97 - 98 - 99 - 100 - 101 - 102 - 103 - 104 - 105 - 106 - 107 - 108 - 109 - 110 - 111 - 112 - 113 - 114 - 115 - 116 - 117 - 118 - 119 - 120 - 121 - 122 - 123 - 124 - 125 - 126 - 127 - 128 - 129 - 130 - 131 - 132 - 133 - 134 - 135 - 136 - 137 - 138 - 139 - 140 - 141 - 142 - 143 - 144 - 145 - 146 - 147 - 148 - 149 - 150 - 151 - 152 - 153 - 154 - 155 - 156 - 157 - 158 - 159 - 160 - 161 - 162 - 163 - 164 - 165 - 166 - 167 - 168 - 169 - 170 - 171 - 172 - 173 - 174 - 175 - 176 - 177 - 178 - 179 - 180 - 181 - 182 - 183 - 184 - 185 - 186 - 187 - 188 - 189 - 190 - 191 - 192 - 193 - 194 - 195 - 196 - 197 - 198 - 199 - 200 - 201 - 202 - 203 - 204 - 205 - 206 - 207 - 208 - 209 - 210 - 211 - 212 - 213 - 214 - 215 - 216 - 217 - 218 - 219 - 220 - 221 - 222 - 223 - 224 - 225 - 226 - 227 - 228 - 229 - 230 - 231 - 232 - 233 - 234 - 235 - 236 - 237 - 238 - 239 - 240 - 241 - 242 - 243 - 244 - 245 - 246 - 247 - 248 - 249 - 250 - 251 - 252 - 253 - 254 - 255 - 256 - 257 - 258 - 259 - 260 - 261 - 262 - 263 - 264 - 265 - 266 - 267 - 268 - 269 - 270 - 271 - 272 - 273 - 274 - 275 - 276 - 277 - 278 - 279 - 280 - 281 - 282 - 283 - 284 - 285 - 286 - 287 - 288 - 289 - 290 - 291 - 292 - 293 - 294 - 295 - 296 - 297 - 298 - 299 - 300 - 301 - 302 - 303 - 304 - 305 - 306 - 307 - 308 - 309 - 310 - 311 - 312 - 313 - 314 - 315 - 316 - 317 - 318 - 319 - 320 - 321 - 322 - 323 - 324 - 325 - 326 - 327 - 328 - 329 - 330 - 331 - 332 - 333 - 334 - 335 - 336 - 337 - 338 - 339 - 340 - 341 - 342 - 343 - 344 - 345 - 346 - 347 - 348 - 349 - 350 - 351 - 352 - 353 - 354 - 355 - 356 - 357 - 358 - 359 - 360 - 361 - 362 - 363 - 364 - 365 - 366 - 367 - 368 - 369 - 370 - 371 - 372 - 373 - 374 - 375 - 376 - 377 - 378 - 379 - 380 - 381 - 382 - 383 - 384 - 385 - 386 - 387 - 388 - 389 - 390 - 391 - 392 - 393 - 394 - 395 - 396 - 397 - 398 - 399 - 400 - 401 - 402 - 403 - 404 - 405 - 406 - 407 - 408 - 409 - 410 - 411 - 412 - 413 - 414 - 415 - 416 - 417 - 418 - 419 - 420 - 421 - 422 - 423 - 424 - 425 - 426 - 427 - 428 - 429 - 430 - 431 - 432 - 433 - 434 - 435 - 436 - 437 - 438 - 439 - 440 - 441 - 442 - 443 - 444 - 445 - 446 - 447 - 448 - 449 - 450 - 451 - 452 - 453 - 454 - 455 - 456 - 457 - 458 - 459 - 460 - 461 - 462 - 463 - 464 - 465 - 466 - 467 - 468 - 469 - 470 - 471 - 472 - 473 - 474 - 475 - 476 - 477 - 478 - 479 - 480 - 481 - 482 - 483 - 484 - 485 - 486 - 487 - 488 - 489 - 490 - 491 - 492 - 493 - 494 - 495 - 496 - 497 - 498 - 499 - 500 - 501 - 502 - 503 - 504 - 505 - 506 - 507 - 508 - 509 - 510 - 511 - 512 - 513 - 514 - 515 - 516 - 517 - 518 - 519 - 520 - 521 - 522 - 523 - 524 - 525 - 526 - 527 - 528 - 529 - 530 - 531 - 532 - 533 - 534 - 535 - 536 - 537 - 538 - 539 - 540 - 541 - 542 - 543 - 544 - 545 - 546 - 547 - 548 - 549 - 550 - 551 - 552 - 553 - 554 - 555 - 556 - 557 - 558 - 559 - 560 - 561 - 562 - 563 - 564 - 565 - 566 - 567 - 568 - 569 - 570 - 571 - 572 - 573 - 574 - 575 - 576 - 577 - 578 - 579 - 580 - 581 - 582 - 583 - 584 - 585 - 586 - 587 - 588 - 589 - 590 - 591 - 592 - 593 - 594 - 595 - 596 - 597 - 598 - 599 - 600 - 601 - 602 - 603 - 604 - 605 - 606 - 607 - 608 - 609 - 610 - 611 - 612 - 613 - 614 - 615 - 616 - 617 - 618 - 619 - 620 - 621 - 622 - 623 - 624 - 625 - 626 - 627 - 628 - 629 - 630 - 631 - 632 - 633 - 634 - 635 - 636 - 637 - 638 - 639 - 640 - 641 - 642 - 643 - 644 - 645 - 646 - 647 - 648 - 649 - 650 - 651 - 652 - 653 - 654 - 655 - 656 - 657 - 658 - 659 - 660 - 661 - 662 - 663 - 664 - 665 - 666 - 667 - 668 - 669 - 670 - 671 - 672 - 673 - 674 - 675 - 676 - 677 - 678 - 679 - 680 - 681 - 682 - 683 - 684 - 685 - 686 - 687 - 688 - 689 - 690 - 691 - 692 - 693 - 694 - 695 - 696 - 697 - 698 - 699 - 700 - 701 - 702 - 703 - 704 - 705 - 706 - 707 - 708 - 709 - 710 - 711 - 712 - 713 - 714 - 715 - 716 - 717 - 718 - 719 - 720 - 721 - 722 - 723 - 724 - 725 - 726 - 727 - 728 - 729 - 730 - 731 - 732 - 733 - 734 - 735 - 736 - 737 - 738 - 739 - 740 - 741 - 742 - 743 - 744 - 745 - 746 - 747 - 748 - 749 - 750 - 751 - 752 - 753 - 754 - 755 - 756 - 757 - 758 - 759 - 760 - 761 - 762 - 763 - 764 - 765 - 766 - 767 - 768 - 769 - 770 - 771 - 772 - 773 - 774 - 775 - 776 - 777 - 778 - 779 - 780 - 781 - 782 - 783 - 784 - 785 - 786 - 787 - 788 - 789 - 790 - 791 - 792 - 793 - 794 - 795 - 796 - 797 - 798 - 799 - 800 - 801 - 802 - 803 - 804 - 805 - 806 - 807 - 808 - 809 - 810 - 811 - 812 - 813 - 814 - 815 - 816 - 817 - 818 - 819 - 820 - 821 - 822 - 823 - 824 - 825 - 826 - 827 - 828 - 829 - 830 - 831 - 832 - 833 - 834 - 835 - 836 - 837 - 838 - 839 - 840 - 841 - 842 - 843 - 844 - 845 - 846 - 847 - 848 - 849 - 850 - 851 - 852 - 853 - 854 - 855 - 856 - 857 - 858 - 859 - 860 - 861 - 862 - 863 - 864 - 865 - 866 - 867 - 868 - 869 - 870 - 871 - 872 - 873 - 874 - 875 - 876 - 877 - 878 - 879 - 880 - 881 - 882 - 883 - 884 - 885 - 886 - 887 - 888 - 889 - 890 - 891 - 892 - 893 - 894 - 895 - 896 - 897 - 898 - 899 - 900 - 901 - 902 - 903 - 904 - 905 - 906 - 907 - 908 - 909 - 910 - 911 - 912 - 913 - 914 - 915 - 916 - 917 - 918 - 919 - 920 - 921 - 922 - 923 - 924 - 925 - 926 - 927 - 928 - 929 - 930 - 931 - 932 - 933 - 934 - 935 - 936 - 937 - 938 - 939 - 940 - 941 - 942 - 943 - 944 - 945 - 946 - 947 - 948 - 949 - 950 - 951 - 952 - 953 - 954 - 955 - 956 - 957 - 958 - 959 - 960 - 961 - 962 - 963 - 964 - 965 - 966 - 967 - 968 - 969 - 970 - 971 - 972 - 973 - 974 - 975 - 976 - 977 - 978 - 979 - 980 - 981 - 982 - 983 - 984 - 985 - 986 - 987 - 988 - 989 - 990 - 991 - 992 - 993 - 994 - 995 - 996 - 997 - 998 - 999 -1000 -1001 -1002 -1003 -1004 -1005 -1006 -1007 -1008 -1009 -1010 -1011 -1012 -1013 -1014 -1015 -1016 -1017 -1018 -1019 -1020 -1021 -1022 -1023 -1024 -1025 -1026 -1027 -1028 -1029 -1030 -1031 -1032 -1033 -1034 -1035 -1036 -1037 -1038 -1039 -1040 -1041 -1042 -1043 -1044 -1045 -1046 -1047 -1048 -1049 -1050 -1051 -1052 -1053 -1054 -1055 -1056 -1057 -1058 -1059 -1060 -1061 -1062 -1063 -1064 -1065 -1066 -1067 -1068 -1069 -1070 -1071 -1072 -1073 -1074 -1075 -1076 -1077 -1078 -1079 -1080 -1081 -1082 -1083 -1084 -1085 -1086 -1087 -1088 -1089 -1090 -1091 -1092 -1093 -1094 -1095 -1096 -1097 -1098 -1099 -1100 -1101 -1102 -1103 -1104 -1105 -1106 -1107 -1108 -1109 -1110 -1111 -1112 -1113 -1114 -1115 -1116 -1117 -1118 -1119 -1120 -1121 -1122 -1123 -1124 -1125 -1126 -1127 -1128 -1129 -1130 -1131 -1132 -1133 -1134 -1135 -1136 -1137 -1138 -1139 -1140 -1141 -1142 -1143 -1144 -1145 -1146 -1147 -1148 -1149 -1150 -1151 -1152 -1153 -1154 -1155 -1156 -1157 -1158 -1159 -1160 -1161 -1162 -1163 -1164 -1165 -1166 -1167 -1168 -1169 -1170 -1171 -1172 -1173 -1174 -1175 -1176 -1177 -1178 -1179 -1180 -1181 -1182 -1183 -1184 -1185 -1186 -1187 -1188 -1189 -1190 -1191 -1192 -1193 -1194 -1195 -1196 -1197 -1198 -1199 -1200 -1201 -1202 -1203 -1204 -1205 -1206 -1207 -1208 -1209 -1210 -1211 -1212 -1213 -1214 -1215 -1216 -1217 -1218 -1219 -1220 -1221 -1222 -1223 -1224 -1225 -1226 -1227 -1228 -1229 -1230 -1231 -1232 -1233 -1234 -1235 -1236 -1237 -1238 -1239 -1240 -1241 -1242 -1243 -1244 -1245 -1246 -1247 -1248 -1249 -1250 -1251 -1252 -1253 -1254 -1255 -1256 -1257 -1258 -1259 -1260 -1261 -1262 -1263 -1264 -1265 -1266 -1267 -1268 -1269 -1270 -1271 -1272 -1273 -1274 -1275 -1276 -1277 -1278 -1279 -1280 -1281 -1282 -1283 -1284 -1285 -1286 -1287 -1288 -1289 -1290 -1291 -1292 -1293 -1294 -1295 -1296 -1297 -1298 -1299 -1300 -1301 -1302 -1303 -1304 -1305 -1306 -1307 -1308 -1309 -1310 -1311 -1312 -1313 -1314 -1315 -1316 -1317 -1318 -1319 -1320 -1321 -1322 -1323 -1324 -1325 -1326 -1327 -1328 -1329 -1330 -1331 -1332 -1333 -1334 -1335 -1336 -1337 -1338 -1339 -1340 -1341 -1342 -1343 -1344 -1345 -1346 -1347 -1348 -1349 -1350 -1351 -1352 -1353 -1354 -1355 -1356 -1357 -1358 -1359 -1360 -1361 -1362 -1363 -1364 -1365 -1366 -1367 -1368 -1369 -1370 -1371 -1372 -1373 -1374 -1375 -1376 -1377 -1378 -1379 -1380 -1381 -1382 -1383 -1384 -1385 -1386 -1387 -1388 -1389 -1390 -1391 -1392 -1393 -1394 -1395 -1396 -1397 -1398 -1399 -1400 -1401 -1402 -1403 -1404 -1405 -1406 -1407 -1408 -1409 -1410 -1411 -1412 -1413 -1414 -1415 -1416 -1417 -1418 -1419 -1420 -1421 -1422 -1423 -1424 -1425 -1426 -1427 -1428 -1429 -1430 -1431 -1432 -1433 -1434 -1435 -1436 -1437 -1438 -1439 -1440 -1441 -1442 -1443 -1444 -1445 -1446 -1447 -1448 -1449 -1450 -1451 -1452 -1453 -1454 -1455 -1456 -1457 -1458 -1459 -1460 -1461 -1462 -1463 -1464 -1465 -1466 -1467 -1468 -1469 -1470 -1471 -1472 -1473 -1474 -1475 -1476 -1477 -1478 -1479 -1480 -1481 -1482 -1483 -1484 -1485 -1486 -1487 -1488 -1489 -1490 -1491 -1492 -1493 -1494 -1495 -1496 -1497 -1498 -1499 -1500 -1501 -1502 -1503 -1504 -1505 -1506 -1507 -1508 -1509 -1510 -1511 -1512 -1513 -1514 -1515 -1516 -1517 -1518 -1519 -1520 -1521 -1522 -1523 -1524 -1525 -1526 -1527 -1528 -1529 -1530 -1531 -1532 -1533 -1534 -1535 -1536 -1537 -1538 -1539 -1540 -1541 -1542 -1543 -1544 -1545 -1546 -1547 -1548 -1549 -1550 -1551 -1552 -1553 -1554 -1555 -1556 -1557 -1558 -1559 -1560 -1561 -1562 -1563 -1564 -1565 -1566 -1567 -1568 -1569 -1570 -1571 -1572 -1573 -1574 -1575 -1576 -1577 -1578 -1579 -1580 -1581 -1582 -1583 -1584 -1585 -1586 -1587 -1588 -1589 -1590 -1591 -1592 -1593 -1594 -1595 -1596 -1597 -1598 -1599 -1600 -1601 -1602 -1603 -1604 -1605 -1606 -1607 -1608 -1609 -1610 -1611 -1612 -1613 -1614 -1615 -1616 -1617 -1618 -1619 -1620 -1621 -1622 -1623 -1624 -1625 -1626 -1627 -1628 -1629 -1630 -1631 -1632 -1633 -1634 -1635 -1636 -1637 -1638 -1639 -1640 -1641 -1642 -1643 -1644 -1645 -1646 -1647 -1648 -1649 -1650 -1651 -1652 -1653 -1654 -1655 -1656 -1657 -1658 -1659 -1660 -1661 -1662 -1663 -1664 -1665 -1666 -1667 -1668 -1669 -1670 -1671 -1672 -1673 -1674 -1675 -1676 -1677 -1678 -1679 -1680 -1681 -1682 -1683 -1684 -1685 -1686 -1687 -1688 -1689 -1690 -1691 -1692 -1693 -1694 -1695 -1696 -1697 -1698 -1699 -1700 -1701 -1702 -1703 -1704 -1705 -1706 -1707 -1708 -1709 -1710 -1711 -1712 -1713 -1714 -1715 -1716 -1717 -1718 -1719 -1720 -1721 -1722 -1723 -1724 -1725 -1726 -1727 -1728 -1729 -1730 -1731 -1732 -1733 -1734 -1735 -1736 -1737 -1738 -1739 -1740 -1741 -1742 -1743 -1744 -1745 -1746 -1747 -1748 -1749 -1750 -1751 -1752 -1753 -1754 -1755 -1756 -1757 -1758 -1759 -1760 -1761 -1762 -1763 -1764 -1765 -1766 -1767 -1768 -1769 -1770 -1771 -1772 -1773 -1774 -1775 -1776 -1777 -1778 -1779 -1780 -1781 -1782 -1783 -1784 -1785 -1786 -1787 -1788 -1789 -1790 -1791 -1792 -1793 -1794 -1795 -1796 -1797 -1798 -1799 -1800 -1801 -1802 -1803 -1804 -1805 -1806 -1807 -1808 -1809 -1810 -1811 -1812 -1813 -1814 -1815 -1816 -1817 -1818 -1819 -1820 -1821 -1822 -1823 -1824 -1825 -1826 -1827 -1828 -1829 -1830 -1831 -1832 -1833 -1834 -1835 -1836 -1837 -1838 -1839 -1840 -1841 -1842 -1843 -1844 -1845 -1846 -1847 -1848 -1849 -1850 -1851 -1852 -1853 -1854 -1855 -1856 -1857 -1858 -1859 -1860 -1861 -1862 -1863 -1864 -1865 -1866 -1867 -1868 -1869 -1870 -1871 -1872 -1873 -1874 -1875 -1876 -1877 -1878 -1879 -1880 -1881 -1882 -1883 -1884 -1885 -1886 -1887 -1888 -1889 -1890 -1891 -1892 -1893 -1894 -1895 -1896 -1897 -1898 -1899 -1900 -1901 -1902 -1903 -1904 -1905 -1906 -1907 -1908 -1909 -1910 -1911 -1912 -1913 -1914 -1915 -1916 -1917 -1918 -1919 -1920 -1921 -1922 -1923 -1924 -1925 -1926 -1927 -1928 -1929 -1930 -1931 -1932 -1933 -1934 -1935 -1936 -1937 -1938 -1939 -1940 -1941 -1942 -1943 -1944 -1945 -1946 -1947 -1948 -1949 -1950 -1951 -1952 -1953 -1954 -1955 -1956 -1957 -1958 -1959 -1960 -1961 -1962 -1963 -1964 -1965 -1966 -1967 -1968 -1969 -1970 -1971 -1972 -1973 -1974 -1975 -1976 -1977 -1978 -1979 -1980 -1981 -1982 -1983 -1984 -1985 -1986 -1987 -1988 -1989 -1990 -1991 -1992 -1993 -1994 -1995 -1996 -1997 -1998 -1999 -2000 -2001 -2002 -2003 -2004 -2005 -2006 -2007 -2008 -2009 -2010 -2011 -2012 -2013 -2014 -2015 -2016 -2017 -2018 -2019 -2020 -2021 -2022 -2023 -2024 -2025 -2026 -2027 -2028 -2029 -2030 -2031 -2032 -2033 -2034 -2035 -2036 -2037 -2038 -2039 -2040 -2041 -2042 -2043 -2044 -2045 -2046 -2047 -2048 -2049 -2050 -2051 -2052 -2053 -2054 -2055 -2056 -2057 -2058 -2059 -2060 -2061 -2062 -2063 -2064 -2065 -2066 -2067 -2068 -2069 -2070 -2071 -2072 -2073 -2074 -2075 -2076 -2077 -2078 -2079 -2080 -2081 -2082 -2083 -2084 -2085 -2086 -2087 -2088 -2089 -2090 -2091 -2092 -2093 -2094 -2095 -2096 -2097 -2098 -2099 -2100 -2101 -2102 -2103 -2104 -2105 -2106 -2107 -2108 -2109 -2110 -2111 -2112 -2113 -2114 -2115 -2116 -2117 -2118 -2119 -2120 -2121 -2122 -2123 -2124 -2125 -2126 -2127 -2128 -2129 -2130 -2131 -2132 -2133 -2134 -2135 -2136 -2137 -2138 -2139 -2140 -2141 -2142 -2143 -2144 -2145 -2146 -2147 -2148 -2149 -2150 -2151 -2152 -2153 -2154 -2155 -2156 -2157 -2158 -2159 -2160 -2161 -2162 -2163 -2164 -2165 -2166 -2167 -2168 -2169 -2170 -2171 -2172 -2173 -2174 -2175 -2176 -2177 -2178 -2179 -2180 -2181 -2182 -2183 -2184 -2185 -2186 -2187 -2188 -2189 -2190 -2191 -2192 -2193 -2194 -2195 -2196 -2197 -2198 -2199 -2200 -2201 -2202 -2203 -2204 -2205 -2206 -2207 -2208 -2209 -2210 -2211 -2212 -2213 -2214 -2215 -2216 -2217 -2218 -2219 -2220 -2221 -2222 -2223 -2224 -2225 -2226 -2227 -2228 -2229 -2230 -2231 -2232 -2233 -2234 -2235 -2236 -2237 -2238 -2239 -2240 -2241 -2242 -2243 -2244 -2245 -2246 -2247 -2248 -2249 -2250 -2251 -2252 -2253 -2254 -2255 -2256 -2257 -2258 -2259 -2260 -2261 -2262 -2263 -2264 -2265 -2266 -2267 -2268 -2269 -2270 -2271 -2272 -2273 -2274 -2275 -2276 -2277 -2278 -2279 -2280 -2281 -2282 -2283 -2284 -2285 -2286 -2287 -2288 -2289 -2290 -2291 -2292 -2293 -2294 -2295 -2296 -2297 -2298 -2299 -2300 -2301 -2302 -2303 -2304 -2305 -2306 -2307 -2308 -2309 -2310 -2311 -2312 -2313 -2314 -2315 -2316 -2317 -2318 -2319 -2320 -2321 -2322 -2323 -2324 -2325 -2326 -2327 -2328 -2329 -2330 -2331 -2332 -2333 -2334 -2335 -2336 -2337 -2338 -2339 -2340 -2341 -2342 -2343 -2344 -2345 -2346 -2347 -2348 -2349 -2350 -2351 -2352 -2353 -2354 -2355 -2356 -2357 -2358 -2359 -2360 -2361 -2362 -2363 -2364 -2365 -2366 -2367 -2368 -2369 -2370 -2371 -2372 -2373 -2374 -2375 -2376 -2377 -2378 -2379 -2380 -2381 -2382 -2383 -2384 -2385 -2386 -2387 -2388 -2389 -2390 -2391 -2392 -2393 -2394 -2395 -2396 -2397 -2398 -2399 -2400 -2401 -2402 -2403 -2404 -2405 -2406 -2407 -2408 -2409 -2410 -2411 -2412 -2413 -2414 -2415 -2416 -2417 -2418 -2419 -2420 -2421 -2422 -2423 -2424 -2425 -2426 -2427 -2428 -2429 -2430 -2431 -2432 -2433 -2434 -2435 -2436 -2437 -2438 -2439 -2440 -2441 -2442 -2443 -2444 -2445 -2446 -2447 -2448 -2449 -2450 -2451 -2452 -2453 -2454 -2455 -2456 -2457 -2458 -2459 -2460 -2461 -2462 -2463 -2464 -2465 -2466 -2467 -2468 -2469 -2470 -2471 -2472 -2473 -2474 -2475 -2476 -2477 -2478 -2479 -2480 -2481 -2482 -2483 -2484 -2485 -2486 -2487 -2488 -2489 -2490 -2491 -2492 -2493 -2494 -2495 -2496 -2497 -2498 -2499 -2500 -2501 -2502 -2503 -2504 -2505 -2506 -2507 -2508 -2509 -2510 -2511 -2512 -2513 -2514 -2515 -2516 -2517 -2518 -2519 -2520 -2521 -2522 -2523 -2524 -2525 -2526 -2527 -2528 -2529 -2530 -2531 -2532 -2533 -2534 -2535 -2536 -2537 -2538 -2539 -2540 -2541 -2542 -2543 -2544 -2545 -2546 -2547 -2548 -2549 -2550 -2551 -2552 -2553 -2554 -2555 -2556 -2557 -2558 -2559 -2560 -2561 -2562 -2563 -2564 -2565 -2566 -2567 -2568 -2569 -2570 -2571 -2572 -2573 -2574 -2575 -2576 -2577 -2578 -2579 -2580 -2581 -2582 -2583 -2584 -2585 -2586 -2587 -2588 -2589 -2590 -2591 -2592 -2593 -2594 -2595 -2596 -2597 -2598 -2599 -2600 -2601 -2602 -2603 -2604 -2605 -2606 -2607 -2608 -2609 -2610 -2611 -2612 -2613 -2614 -2615 -2616 -2617 -2618 -2619 -2620 -2621 -2622 -2623 -2624 -2625 -2626 -2627 -2628 -2629 -2630 -2631 -2632 -2633 -2634 -2635 -2636 -2637 -2638 -2639 -2640 -2641 -2642 -2643 -2644 -2645 -2646 -2647 -2648 -2649 -2650 -2651 -2652 -2653 -2654 -2655 -2656 -2657 -2658 -2659 -2660 -2661 -2662 -2663 -2664 -2665 -2666 -2667 -2668 -2669 -2670 -2671 -2672 -2673 -2674 -2675 -2676 -2677 -2678 -2679 -2680 -2681 -2682 -2683 -2684 -2685 -2686 -2687 -2688 -2689 -2690 -2691 -2692 -2693 -2694 -2695 -2696 -2697 -2698 -2699 -2700 -2701 -2702 -2703 -2704 -2705 -2706 -2707 -2708 -2709 -2710 -2711 -2712 -2713 -2714 -2715 -2716 -2717 -2718 -2719 -2720 -2721 -2722 -2723 -2724 -2725 -2726 -2727 -2728 -2729 -2730 -2731 -2732 -2733 -2734 -2735 -2736 -2737 -2738 -2739 -2740 -2741 -2742 -2743 -2744 -2745 -2746 -2747 -2748 -2749 -2750 -2751 -2752 -2753 -2754 -2755 -2756 -2757 -2758 -2759 -2760 -2761 -2762 -2763 -2764 -2765 -2766 -2767 -2768 -2769 -2770 -2771 -2772 -2773 -2774 -2775 -2776 -2777 -2778 -2779 -2780 -2781 -2782 -2783 -2784 -2785 -2786 -2787 -2788 -2789 -2790 -2791 -2792 -2793 -2794 -2795 -2796 -2797 -2798 -2799 -2800 -2801 -2802 -2803 -2804 -2805 -2806 -2807 -2808 -2809 -2810 -2811 -2812 -2813 -2814 -2815 -2816 -2817 -2818 -2819 -2820 -2821 -2822 -2823 -2824 -2825 -2826 -2827 -2828 -2829 -2830 -2831 -2832 -2833 -2834 -2835 -2836 -2837 -2838 -2839 -2840 -2841 -2842 -2843 -2844 -2845 -2846 -2847 -2848 -2849 -2850 -2851 -2852 -2853 -2854 -2855 -2856 -2857 -2858 -2859 -2860 -2861 -2862 -2863 -2864 -2865 -2866 -2867 -2868 -2869 -2870 -2871 -2872 -2873 -2874 -2875 -2876 -2877 -2878 -2879 -2880 -2881 -2882 -2883 -2884 -2885 -2886 -2887 -2888 -2889 -2890 -2891 -2892 -2893 -2894 -2895 -2896 -2897 -2898 -2899 -2900 -2901 -2902 -2903 -2904 -2905 -2906 -2907 -2908 -2909 -2910 -2911 -2912 -2913 -2914 -2915 -2916 -2917 -2918 -2919 -2920 -2921 -2922 -2923 -2924 -2925 -2926 -2927 -2928 -2929 -2930 -2931 -2932 -2933 -2934 -2935 -2936 -2937 -2938 -2939 -2940 -2941 -2942 -2943 -2944 -2945 -2946 -2947 -2948 -2949 -2950 -2951 -2952 -2953 -2954 -2955 -2956 -2957 -2958 -2959 -2960 -2961 -2962 -2963 -2964 -2965 -2966 -2967 -2968 -2969 -2970 -2971 -2972 -2973 -2974 -2975 -2976 -2977 -2978 -2979 -2980 -2981 -2982 -2983 -2984 -2985 -2986 -2987 -2988 -2989 -2990 -2991 -2992 -2993 -2994 -2995 -2996 -2997 -2998 -2999 -3000 -3001 -3002 -3003 -3004 -3005 -3006 -3007 -3008 -3009 -3010 -3011 -3012 -3013 -3014 -3015 -3016 -3017 -3018 -3019 -3020 -3021 -3022 -3023 -3024 -3025 -3026 -3027 -3028 -3029 -3030 -3031 -3032 -3033 -3034 -3035 -3036 -3037 -3038 -3039 -3040 -3041 -3042 -3043 -3044 -3045 -3046 -3047 -3048 -3049 -3050 -3051 -3052 -3053 -3054 -3055 -3056 -3057 -3058 -3059 -3060 -3061 -3062 -3063 -3064 -3065 -3066 -3067 -3068 -3069 -3070 -3071 -3072 -3073 -3074 -3075 -3076 -3077 -3078 -3079 -3080 -3081 -3082 -3083 -3084 -3085 -3086 -3087 -3088 -3089 -3090 -3091 -3092 -3093 -3094 -3095 -3096 -3097 -3098 -3099 -3100 -3101 -3102 -3103 -3104 -3105 -3106 -3107 -3108 -3109 -3110 -3111 -3112 -3113 -3114 -3115 -3116 -3117 -3118 -3119 -3120 -3121 -3122 -3123 -3124 -3125 -3126 -3127 -3128 -3129 -3130 -3131 -3132 -3133 -3134 -3135 -3136 -3137 -3138 -3139 -3140 -3141 -3142 -3143 -3144 -3145 -3146 -3147 -3148 -3149 -3150 -3151 -3152 -3153 -3154 -3155 -3156 -3157 -3158 -3159 -3160 -3161 -3162 -3163 -3164 -3165 -3166 -3167 -3168 -3169 -3170 -3171 -3172 -3173 -3174 -3175 -3176 -3177 -3178 -3179 -3180 -3181 -3182 -3183 -3184 -3185 -3186 -3187 -3188 -3189 -3190 -3191 -3192 -3193 -3194 -3195 -3196 -3197 -3198 -3199 -3200 -3201 -3202 -3203 -3204 -3205 -3206 -3207 -3208 -3209 -3210 -3211 -3212 -3213 -3214 -3215 -3216 -3217 -3218 -3219 -3220 -3221 -3222 -3223 -3224 -3225 -3226 -3227 -3228 -3229 -3230 -3231 -3232 -3233 -3234 -3235 -3236 -3237 -3238 -3239 -3240 -3241 -3242 -3243 -3244 -3245 -3246 -3247 -3248 -3249 -3250 -3251 -3252 -3253 -3254 -3255 -3256 -3257 -3258 -3259 -3260 -3261 -3262 -3263 -3264 -3265 -3266 -3267 -3268 -3269 -3270 -3271 -3272 -3273 -3274 -3275 -3276 -3277 -3278 -3279 -3280 -3281 -3282 -3283 -3284 -3285 -3286 -3287 -3288 -3289 -3290 -3291 -3292 -3293 -3294 -3295 -3296 -3297 -3298 -3299 -3300 -3301 -3302 -3303 -3304 -3305 -3306 -3307 -3308 -3309 -3310 -3311 -3312 -3313 -3314 -3315 -3316 -3317 -3318 -3319 -3320 -3321 -3322 -3323 -3324 -3325 -3326 -3327 -3328 -3329 -3330 -3331 -3332 -3333 -3334 -3335 -3336 -3337 -3338 -3339 -3340 -3341 -3342 -3343 -3344 -3345 -3346 -3347 -3348 -3349 -3350 -3351 -3352 -3353 -3354 -3355 -3356 -3357 -3358 -3359 -3360 -3361 -3362 -3363 -3364 -3365 -3366 -3367 -3368 -3369 -3370 -3371 -3372 -3373 -3374 -3375 -3376 -3377 -3378 -3379 -3380 -3381 -3382 -3383 -3384 -3385 -3386 -3387 -3388 -3389 -3390 -3391 -3392 -3393 -3394 -3395 -3396 -3397 -3398 -3399 -3400 -3401 -3402 -3403 -3404 -3405 -3406 -3407 -3408 -3409 -3410 -3411 -3412 -3413 -3414 -3415 -3416 -3417 -3418 -3419 -3420 -3421 -3422 -3423 -3424 -3425 -3426 -3427 -3428 -3429 -3430 -3431 -3432 -3433 -3434 -3435 -3436 -3437 -3438 -3439 -3440 -3441 -3442 -3443 -3444 -3445 -3446 -3447 -3448 -3449 -3450 -3451 -3452 -3453 -3454 -3455 -3456 -3457 -3458 -3459 -3460 -3461 -3462 -3463 -3464 -3465 -3466 -3467 -3468 -3469 -3470 -3471 -3472 -3473 -3474 -3475 -3476 -3477 -3478 -3479 -3480 -3481 -3482 -3483 -3484 -3485 -3486 -3487 -3488 -3489 -3490 -3491 -3492 -3493 -3494 -3495 -3496 -3497 -3498 -3499 -3500 -3501 -3502 -3503 -3504 -3505 -3506 -3507 -3508 -3509 -3510 -3511 -3512 -3513 -3514 -3515 -3516 -3517 -3518 -3519 -3520 -3521 -3522 -3523 -3524 -3525 -3526 -3527 -3528 -3529 -3530 -3531 -3532 -3533 -3534 -3535 -3536 -3537 -3538 -3539 -3540 -3541 -3542 -3543 -3544 -3545 -3546 -3547 -3548 -3549 -3550 -3551 -3552 -3553 -3554 -3555 -3556 -3557 -3558 -3559 -3560 -3561 -3562 -3563 -3564 -3565 -3566 -3567 -3568 -3569 -3570 -3571 -3572 -3573 -3574 -3575 -3576 -3577 -3578 -3579 -3580 -3581 -3582 -3583 -3584 -3585 -3586 -3587 -3588 -3589 -3590 -3591 -3592 -3593 -3594 -3595 -3596 -3597 -3598 -3599 -3600 -3601 -3602 -3603 -3604 -3605 -3606 -3607 -3608 -3609 -3610 -3611 -3612 -3613 -3614 -3615 -3616 -3617 -3618 -3619 -3620 -3621 -3622 -3623 -3624 -3625 -3626 -3627 -3628 -3629 -3630 -3631 -3632 -3633 -3634 -3635 -3636 -3637 -3638 -3639 -3640 -3641 -3642 -3643 -3644 -3645 -3646 -3647 -3648 -3649 -3650 -3651 -3652 -3653 -3654 -3655 -3656 -3657 -3658 -3659 -3660 -3661 -3662 -3663 -3664 -3665 -3666 -3667 -3668 -3669 -3670 -3671 -3672 -3673 -3674 -3675 -3676 -3677 -3678 -3679 -3680 -3681 -3682 -3683 -3684 -3685 -3686 -3687 -3688 -3689 -3690 -3691 -3692 -3693 -3694 -3695 -3696 -3697 -3698 -3699 -3700 -3701 -3702 -3703 -3704 -3705 -3706 -3707 -3708 -3709 -3710 -3711 -3712 -3713 -3714 -3715 -3716 -3717 -3718 -3719 -3720 -3721 -3722 -3723 -3724 -3725 -3726 -3727 -3728 -3729 -3730 -3731 -3732 -3733 -3734 -3735 -3736 -3737 -3738 -3739 -3740 -3741 -3742 -3743 -3744 -3745 -3746 -3747 -3748 -3749 -3750 -3751 -3752 -3753 -3754 -3755 -3756 -3757 -3758 -3759 -3760 -3761 -3762 -3763 -3764 -3765 -3766 -3767 -3768 -3769 -3770 -3771 -3772 -3773 -3774 -3775 -3776 -3777 -3778 -3779 -3780 -3781 -3782 -3783 -3784 -3785 -3786 -3787 -3788 -3789 -3790 -3791 -3792 -3793 -3794 -3795 -3796 -3797 -3798 -3799 -3800 -3801 -3802 -3803 -3804 -3805 -3806 -3807 -3808 -3809 -3810 -3811 -3812 -3813 -3814 -3815 -3816 -3817 -3818 -3819 -3820 -3821 -3822 -3823 -3824 -3825 -3826 -3827 -3828 -3829 -3830 -3831 -3832 -3833 -3834 -3835 -3836 -
//!
-//! [](https://crates.io/crates/ubits)
-//! [](https://crates.io/crates/ubits)
-//! [](https://github.com/manoadamro/ubits/actions/workflows/rust.yml)
-//! [](https://manoadamro.github.io/ubits/doc/ubits/)
-//! [](https://github.com/manoadamro/ubits/blob/main/LICENSE)
-//!
-//! Bit fields and masks for rust!
-//!
-//! Provides a macro for generating [`bit field`](https://en.wikipedia.org/wiki/Bit_field) types
-//! complete with flags and some helpful trait implementations.
-//!
-//! Supports field widths of `8`, `16`, `32`, `64` and `128` bits.
-//!
-//! - [`bitfield`] - macro documentation.
-//! - [`examples`] - examples of the output generated by the [`bitfield`] macro.
-//!
-//! __Note: the example module is only complied with documentation builds
-//! and is not available for importing in the wild.__
-//!
-//!
-//! # Usage
-//!
-//! Generate a bitfield struct with a flag enum...
-//! (The following examples all use this as a definition.)
-//! ```rust
-//! use ubits::bitfield;
-//!
-//! bitfield! {
-//! pub u8 ExampleField
-//! ExampleFlags {
-//! 0 : Flag0,
-//! 1 : Flag1,
-//! 2 : Flag2,
-//! 3 : Flag3,
-//! 4 : Flag4,
-//! 5 : Flag5,
-//! 6 : Flag6,
-//! 7 : Flag7,
-//! }
-//! }
-//! ```
-//!
-//! ## Instances
-//!
-//! From integer:
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let from_integer = ExampleField(123);
-//! assert_eq!(ExampleField(123), from_integer);
-//! ```
-//!
-//! From a binary string:
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let from_binary = ExampleField::from_binary_str("01111011");
-//! assert_eq!(ExampleField(123), from_binary)
-//! ```
-//!
-//! From ones:
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let from_ones = ExampleField::ones();
-//! assert_eq!("11111111", from_ones.as_binary());
-//! assert_eq!(255, from_ones.as_integer());
-//! ```
-//!
-//! From zeros:
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let from_zeros = ExampleField::zeros();
-//! assert_eq!("00000000", from_zeros.as_binary());
-//! assert_eq!(0, from_zeros.as_integer());
-//! ```
-//!
-//! ### Field Access
-//!
-//! Get bit value by field:
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let field = ExampleField::from_binary_str("01010101");
-//! assert!(field.get(ExampleFlags::Flag0));
-//! assert!(!field.get(ExampleFlags::Flag1));
-//! ```
-//!
-//! Get bit value by index:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let field = ExampleField::from_binary_str("01010101");
-//! assert!(field.get_index(0));
-//! assert!(!field.get_index(1));
-//! ```
-//!
-//! Set bit value by field:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut field = ExampleField::from_binary_str("01010101");
-//! field.set(ExampleFlags::Flag1);
-//! field.set(ExampleFlags::Flag3);
-//! assert_eq!("01011111", field.as_binary());
-//! ```
-//!
-//! Set bit value by index:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut field = ExampleField::from_binary_str("01010101");
-//! field.set_index(1);
-//! field.set_index(3);
-//! assert_eq!("01011111", field.as_binary());
-//! ```
-//!
-//! Clear bit value by field:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut field = ExampleField::from_binary_str("01010101");
-//! field.clear(ExampleFlags::Flag0);
-//! field.clear(ExampleFlags::Flag2);
-//! assert_eq!("01010000", field.as_binary());
-//! ```
-//!
-//! Clear bit value by index:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut field = ExampleField::from_binary_str("01010101");
-//! field.clear_index(0);
-//! field.clear_index(2);
-//! assert_eq!("01010000", field.as_binary());
-//! ```
-//!
-//! Toggle bit value by field:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut field = ExampleField::from_binary_str("01010101");
-//! field.toggle(ExampleFlags::Flag0);
-//! assert_eq!("01010100", field.as_binary());
-//! field.toggle(ExampleFlags::Flag0);
-//! assert_eq!("01010101", field.as_binary());
-//! ```
-//!
-//! Toggle bit value by index:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut field = ExampleField::from_binary_str("01010101");
-//! field.toggle_index(0);
-//! assert_eq!("01010100", field.as_binary());
-//! field.toggle_index(0);
-//! assert_eq!("01010101", field.as_binary());
-//! ```
-//!
-//! ### Named Getters and Setters
-//!
-//! Ubits can generate getter and setter methods for zero or more fields, if a name is provided.
-//!
-//! ```rust
-//! use ubits::bitfield;
-//! bitfield! {
-//! pub u8 ExampleField
-//! ExampleFlags {
-//! 0 : Flag0 : (field_0), // is_field_0 & set_field_0 & clear_field_0 & toggle_field_0
-//! 1 : Flag1 : (field_1), // is_field_1 & set_field_1 & clear_field_1 & toggle_field_1
-//! 2 : Flag2,
-//! 3 : Flag3,
-//! 4 : Flag4,
-//! 5 : Flag5,
-//! 6 : Flag6,
-//! 7 : Flag7,
-//! }
-//! }
-//!
-//! let mut field = ExampleField::from_binary_str("01010101");
-//! assert_eq!(true, field.is_field_0());
-//! assert_eq!(false, field.is_field_1());
-//!
-//! field.set_field_1();
-//! assert_eq!(true, field.is_field_1());
-//!
-//! field.clear_field_1();
-//! assert_eq!(false, field.is_field_1());
-//!
-//! field.toggle_field_1();
-//! assert_eq!(true, field.is_field_1());
-//! ```
-//!
-//! ### Combinations
-//!
-//! Combine bit fields: <br>
-//! (use `into_combined` to consume self)
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut a = ExampleField::from_binary_str("01010101");
-//! let b = ExampleField::from_binary_str("10101010");
-//! assert_eq!("11111111", a.combine(b).as_binary());
-//! ```
-//!
-//! Get the intersection of two bitfields: <br>
-//! (use `into_intersection` to consume self)
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut a = ExampleField::from_binary_str("11000011");
-//! let b = ExampleField::from_binary_str("01111110");
-//! assert_eq!("01000010", a.intersect(b).as_binary());
-//! ```
-//!
-//! Get the diff of two bitfields: <br>
-//! (use `into_diff` to consume self)
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut a = ExampleField::from_binary_str("11000011");
-//! let b = ExampleField::from_binary_str("01100110");
-//! assert_eq!("10100101", a.diff(b).as_binary());
-//! ```
-//!
-//! ### Bitwise
-//!
-//! Both bit field instances and flags use bitwise operators to change bit values.
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut from_zeros = ExampleField::zeros();
-//! assert_eq!("00000000", from_zeros.as_binary());
-//!
-//! // set bit to 1
-//! from_zeros |= ExampleFlags::Flag1;
-//! assert_eq!("00000010", from_zeros.as_binary());
-//!
-//! // set bit back to 0
-//! from_zeros &= ExampleFlags::Flag1;
-//! assert_eq!("00000000", from_zeros.as_binary());
-//!
-//! // toggle a bit
-//! from_zeros ^= ExampleFlags::Flag1;
-//! assert_eq!("00000010", from_zeros.as_binary());
-//!
-//! from_zeros ^= ExampleFlags::Flag1;
-//! assert_eq!("00000000", from_zeros.as_binary());
-//! ```
-//!
-//! Operations can also be chained together:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut from_zeros = ExampleField::zeros() | ExampleFlags::Flag1 | ExampleFlags::Flag3;
-//! assert_eq!("00001010", from_zeros.as_binary());
-//!
-//! ```
-//!
-//! Bitfield instances can also be created from combining flags:
-//!
-//! ```rust
-//! # use ubits::bitfield;
-//! # bitfield! {
-//! # pub u8 ExampleField
-//! # ExampleFlags {
-//! # 0 : Flag0,
-//! # 1 : Flag1,
-//! # 2 : Flag2,
-//! # 3 : Flag3,
-//! # 4 : Flag4,
-//! # 5 : Flag5,
-//! # 6 : Flag6,
-//! # 7 : Flag7,
-//! # }
-//! # }
-//!
-//! let mut from_zeros = ExampleFlags::Flag1 | ExampleFlags::Flag3;
-//! assert_eq!("00001010", from_zeros.as_binary());
-//!
-//! ```
-//!
-//! ## Fields named with flags
-//!
-//! The generated flags enum allows you to access bits by name.
-//! The flag has an associated [`u8`] value,
-//! which determines the index its target bit.
-//! (See [`bitfield`] for more info)
-//!
-//! With the following input...
-//! ```no_compile
-//! 1 0 1 0 0 1 1 0
-//! ```
-//!
-//! and the following flags...
-//! ```no_compile
-//! 0 : f1
-//! 1 : f1
-//! 2 : f2
-//! 3 : f3
-//! 4 : f4
-//! 5 : f5
-//! 6 : f6
-//! 7 : f7
-//! ```
-//!
-//! we end up with this layout.
-//!
-//! | name | f7 | f6 | f5 | f4 | f3 | f2 | f1 | f0 |
-//! |-----------|----|----|----|----|----|----|----|----|
-//! | bit value | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
-//! | index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
-//!
-//!
-//! With the same input and only the first few flags:
-//!
-//! ```no_compile
-//! 0 : f0
-//! 1 : f1
-//! 2 : f2
-//! ```
-//!
-//! we end up with this layout.
-//!
-//! | name | | | | | | f2 | f1 | f0 |
-//! |-----------|----|----|----|----|----|----|----|----|
-//! | bit value | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
-//! | index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
-//!
-//!
-//! Using the same input, but with dispersed flags:
-//!
-//! ```no_compile
-//! 1 : f0
-//! 3 : f1
-//! 6 : f2
-//! ```
-//!
-//! we end up with this layout.
-//!
-//! | name | | f2 | | | f1 | | f0 | |
-//! |-----------|----|----|----|----|----|----|----|----|
-//! | bit value | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
-//! | index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
-//!
-
-// -------------------------------------------------------------------------------------------------
-// Imports
-
-extern crate doc_comment;
-extern crate paste;
-extern crate safe_transmute;
-
-#[doc(hidden)]
-pub use doc_comment::doc_comment as __doc_comment;
-
-#[doc(hidden)]
-pub use safe_transmute::{
- transmute_one as __transmute_one, TriviallyTransmutable as __TriviallyTransmutable,
-};
-
-#[doc(hidden)]
-pub use paste::paste as __paste;
-
-// -------------------------------------------------------------------------------------------------
-// Generator Macros
-
-/// Generates a bitfield struct and a corresponding flag enum.
-///
-/// Can be used multiple times in a single codebase
-/// as long as the identifiers are unique or are isolated so as not to clash.
-///
-/// __See the [`examples`] module for examples of the generated output.__
-///
-/// # Args
-///
-/// - `pub` - optional accessor: if provided, both generated items will public.
-/// If omitted, both will be private. <br>
-/// [see here](https://doc.rust-lang.org/reference/visibility-and-privacy.html#visibility-and-privacy) for possible visibility options.
-///
-/// - `ExampleField` - name for the generated bitfield struct.
-/// (results in `struct ExampleField(...)`)
-///
-/// - `ExampleFlags` - name for the generated flag enum.
-/// (results in `enum ExampleFlags { ... }`)
-///
-/// - `u8` - unsigned integer type to use as a bit array. *Must be an unsigned integer* <br>
-/// valid options are: [`u8`],[`u16`], [`u32`], [`u64`], [`u128`], [`usize`]
-///
-/// - `0 : Flag0` - defines each member of the flag enum. <br>
-/// The left hand side must be a [`u8`] `(0..=254)`
-/// and must be less than the number of bits in the underlying unsigned type.
-/// This value determines the index of the target bit within the field. <br>
-/// The right hand side can be any valid identifier (unique to this enum).
-/// These identifiers will be used to access the corresponding field.
-///
-/// - `/// docstrings` - Each element can take optional docstrings.
-/// This includes the bit field struct, the flag enum, and each member within the flag enum.
-/// See [`examples`] for more information.
-///
-/// # Examples:
-///
-/// Full Example - (see below for explanation for each parameter):
-/// ```rust
-/// use ubits::bitfield;
-///
-/// bitfield! {
-/// /// Optional docstring
-/// /// for [`ExampleField`] struct
-/// pub u8 ExampleField
-/// /// Optional docstring
-/// /// for [`ExampleFlags`] enum
-/// ExampleFlags {
-/// /// Optional docstring for [`ExampleFlags::Flag0`]
-/// 0 : Flag0,
-/// /// Optional docstring for [`ExampleFlags::Flag1`]
-/// 1 : Flag1,
-/// /// Optional docstring for [`ExampleFlags::Flag2`]
-/// 2 : Flag2,
-/// /// Optional docstring for [`ExampleFlags::Flag3`]
-/// 3 : Flag3,
-/// /// Optional docstring for [`ExampleFlags::Flag4`]
-/// 4 : Flag4,
-/// /// Optional docstring for [`ExampleFlags::Flag5`]
-/// 5 : Flag5,
-/// /// Optional docstring for [`ExampleFlags::Flag6`]
-/// 6 : Flag6,
-/// /// Optional docstring for [`ExampleFlags::Flag7`]
-/// 7 : Flag7,
-/// }
-/// }
-/// ```
-///
-/// You don't have to name *all* the fields if you don't need them...
-///
-/// You can use just a few from the front:
-/// ```rust
-/// use ubits::bitfield;
-///
-/// bitfield! {
-/// /// Optional docstring
-/// /// for [`ExampleField`] struct
-/// pub u8 ExampleField
-/// /// Optional docstring
-/// /// for [`ExampleFlags`] enum
-/// ExampleFlags {
-/// /// Optional docstring for [`ExampleFlags::Flag0`]
-/// 0 : Flag0,
-/// /// Optional docstring for [`ExampleFlags::Flag1`]
-/// 1 : Flag1,
-/// /// Optional docstring for [`ExampleFlags::Flag2`]
-/// 2 : Flag2,
-/// }
-/// }
-/// ```
-///
-/// ... or any valid indices:
-/// ```rust
-/// use ubits::bitfield;
-///
-/// bitfield! {
-/// /// Optional docstring
-/// /// for [`ExampleField`] struct
-/// pub u8 ExampleField
-/// /// Optional docstring
-/// /// for [`ExampleFlags`] enum
-/// ExampleFlags {
-/// /// Optional docstring for [`ExampleFlags::Flag0`]
-/// 0 : Flag0,
-/// /// Optional docstring for [`ExampleFlags::Flag1`]
-/// 3 : Flag1,
-/// /// Optional docstring for [`ExampleFlags::Flag2`]
-/// 6 : Flag2,
-/// }
-/// }
-/// ```
-/// ... or just omit the flags altogether and use indices only.:
-/// ```rust
-/// use ubits::bitfield;
-/// bitfield! {
-/// /// Optional docstring
-/// /// for [`ExampleField`] struct
-/// pub u8 ExampleField
-/// }
-/// ```
-/// __Note: if you omit flags, no flag enum will be generated
-/// and no methods for the bitfield struct that rely on flags will be generated.__
-///
-#[macro_export(local_inner_macros)]
-macro_rules! bitfield {
-
- // U8
- (
- $(#[$doc:meta])*
- $access:vis u8 $name:ident
- $(
- $(#[$flag_doc:meta])*
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( : ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
- __bitfield_unchecked!( $(#[$doc])* $access [u8] [8] [u8::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
- };
-
- // U16
- (
- $(#[$doc:meta])*
- $access:vis u16 $name:ident
- $(
- $(#[$flag_doc:meta])*
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
- __bitfield_unchecked!( $(#[$doc])* $access [u16] [16] [u16::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
- };
-
- // U32
- (
- $(#[$doc:meta])*
- $access:vis u32 $name:ident
- $(
- $(#[$flag_doc:meta])*
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
- __bitfield_unchecked!( $(#[$doc])* $access [u32] [32] [u32::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
- };
-
- // U64
- (
- $(#[$doc:meta])*
- $access:vis u64 $name:ident
- $(
- $(#[$flag_doc:meta])*
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
- __bitfield_unchecked!( $(#[$doc])* $access [u64] [64] [u64::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
- };
-
- // U128
- (
- $(#[$doc:meta])*
- $access:vis u128 $name:ident
- $(
- $(#[$flag_doc:meta])*
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
- __bitfield_unchecked!( $(#[$doc])* $access [u128] [128] [u128::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
- };
-
- // USIZE
- (
- $(#[$doc:meta])*
- $access:vis usize $name:ident
- $(
- $(#[$flag_doc:meta])*
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
- __bitfield_unchecked!( $(#[$doc])* $access [usize] [usize::BITS as usize] [usize::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
- };
-}
-
-/// Not to be used directly.
-///
-/// Generates a bitfield struct and flag enum
-/// but does no type checking.
-/// Passing types that aren't unsigned integer types is undefined behaviour.
-///
-/// Use the [`bitfield`] macro instead as it enforces a closed set of types.
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! __bitfield_unchecked {
- (
- $(#[$field_doc:meta])*
- $access:vis [$type:ty] [$($bits:tt)*] [$max:path] $name:ident
- $(
- $(#[$flag_doc:meta])*
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
-
- $(
- __def_flag_enum! {
- $(#[$flag_doc])*
- $access $name
- $flag {
- $(
- $(#[$member_doc])*
- $idx : $field $(($named_getter))?,
- )*
- }
- }
- )?
-
- __def_field_struct! {
- $(#[$field_doc])*
- $access [$type] [$($bits)*] [$max] $name
- $(
- $flag {
- $(
- $(#[$member_doc])*
- $idx : $field $(($named_getter))?,
- )*
- }
- )?
- }
- };
-}
-
-// -------------------------------------------------------------------------------------------------
-// Type Definitions
-
-/// Defines a field struct with its members and implementations
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! __def_field_struct {
- (
- $(#[$field_doc:meta])*
- $access:vis [$type:ty] [$($bits:tt)*] [$max:path] $name:ident
- $(
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- )?
- ) => {
-
- // Struct: $name
- $(#[$field_doc])*
- #[derive(Copy, Clone, PartialEq, PartialOrd)]
- $access struct $name($type);
-
- $(
- impl $name {
- $(
- $(
- __paste! {
- fn [< is_ $named_getter >](&self) -> bool {
- self.get($flag::$field)
- }
- }
-
- __paste! {
- fn [< set_ $named_getter >](&mut self) {
- self.set($flag::$field);
- }
- }
-
- __paste! {
- fn [< clear_ $named_getter >](&mut self) {
- self.clear($flag::$field);
- }
- }
-
- __paste! {
- fn [< toggle_ $named_getter >](&mut self) {
- self.toggle($flag::$field);
- }
- }
- )?
- )*
- }
- )?
-
- // Constants
- __impl_field_constants! {
- $name { type: $type, max: $max, bits: [$($bits)*] }
- }
-
- // Constructors
- __impl_field_ctors! {
- $name : $type
- }
-
- // State
- __impl_field_state! {
- $name : $type
- }
-
- // Indexers
- __impl_field_index_accessors! {
- $name
- }
-
- $(
- // Flags
- __impl_field_flag_accessors! {
- $name $flag $type
- }
- )?
-
- // Combinators
- __impl_field_flag_combinators! {
- $name
- }
-
- // Converters
- __impl_field_flag_converters! {
- $name
- }
-
- // Name: $name
- __impl_default! {
- $name => { $name(0) }
- }
-
- // From: $type -> $name
- __impl_from! {
- /// Returns a field instance from value of its underlying type.
- $type as $name (value) => {
- $name(value)
- }
- }
-
- $(
- // From: $flag -> $name
- __impl_from! {
- /// Returns a field instance from a flag.
- $flag as $name (value) => {
- Self(0 | (1 << (value as $type)) )
- }
- }
- )?
-
- // Bitwise: $name + $name
- __impl_bitwise_operators! {
- [Self] for $name : (self rhs -> Self)
- BitAnd => { Self(self.0 & rhs.0) }
- BitOr => { Self(self.0 | rhs.0) }
- BitXor => { Self(self.0 ^ rhs.0) }
- BitAndAssign => { self.0 &= rhs.0; }
- BitOrAssign => { self.0 |= rhs.0; }
- BitXorAssign => { self.0 ^= rhs.0; }
- }
-
- $(
- // Bitwise: $name + $flag
- __impl_bitwise_operators! {
- [$flag] for $name : (self rhs -> $name)
- BitAnd => { $name(self.0 & !(1 << (rhs as $type))) }
- BitOr => { $name(self.0 | (1 << (rhs as $type))) }
- BitXor => { $name(self.0 ^ (1 << (rhs as $type))) }
- BitAndAssign => { self.clear(rhs); }
- BitOrAssign => { self.set(rhs); }
- BitXorAssign => { self.toggle(rhs); }
- }
-
- // Bitwise: &$name + $flag
- __impl_bitwise_operators! {
- [$flag] for & $name : (self rhs -> $name)
- BitAnd => { $name(self.0 & !(1 << (rhs as $type))) }
- BitOr => { $name(self.0 | (1 << (rhs as $type))) }
- BitXor => { $name(self.0 ^ (1 << (rhs as $type))) }
- }
-
- // Bitwise: $mut $name + $flag
- __impl_bitwise_operators! {
- [$flag] for &mut $name : (self rhs -> $name)
- BitAnd => { $name(self.0 & !(1 << (rhs as $type))) }
- BitOr => { $name(self.0 | (1 << (rhs as $type))) }
- BitXor => { $name(self.0 ^ (1 << (rhs as $type))) }
- }
- )?
-
- // Bitwise: Debug & Binary
- __impl_formatters! {
- $name (self f) {
- Debug => { core::write!(f, "{}({})", core::stringify!($name), self.as_binary()) }
- Binary => { core::write!(f, "{}", self.as_binary()) }
- }
- }
- };
-}
-
-/// Defines a flag enum with its members and implementations
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! __def_flag_enum {
- (
- $(#[$flag_doc:meta])*
- $access:vis $name:ident
- $flag:ident {
- $(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
- }
- ) => {
-
- // Enum: $flag
- $(#[$flag_doc])*
- #[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
- #[repr(u8)]
- $access enum $flag {
- $( $(#[$member_doc])* $field = $idx ),*
- }
-
- // Bitwise: $flag + $flag
- __impl_bitwise_operators! {
- [Self] for $flag : (self rhs -> $name)
- BitAnd => { $name(0).clear(self) & rhs }
- BitOr => { $name(0).set(self) | rhs }
- BitXor => { $name(0).toggle(self) ^ rhs }
- }
-
- // Bitwise: u8 -> $flag
- __impl_from! {
- /// Converts a [`u8`] to a flag
- ///
- /// # Errors
- ///
- /// Panics if the supplied [`u8`] is out of range for fields base type.
- /// eg: for a 16-bit field (using [`u16`]),
- /// providing an index of `20` will cause a panic.
- u8 as $flag (value) => {
- $crate::__transmute_one::<$flag>(&[value])
- .expect(std::format!(
- "failed to transmute {} to {}. {} is not a valid index in {}.",
- value,
- core::stringify!($flag),
- value,
- core::stringify!($flag)
- ).as_str())
- }
- }
-
- // Bitwise: $flag -> u8
- __impl_from! {
- /// Returns a flag as its corresponding [`u8`] value.
- $flag as u8 (value) => {
- value as u8
- }
- }
-
- unsafe impl $crate::__TriviallyTransmutable for $flag {}
- };
-}
-
-// -------------------------------------------------------------------------------------------------
-// Field Implementations
-
-/// Generates constants for `$name`
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_field_constants {
- ($name:ident { type: $type:ty, max: $max:path, bits: [$($bits:tt)*] }) => {
- $crate::__doc_comment! {
- core::concat!(
- "Constant values describing [`", core::stringify!($name), "`]."
- ),
- impl $name {
- $crate::__doc_comment! {
- core::concat!(
- "Number of bits in an instance of [`", core::stringify!($name), "`]."
- ),
- pub const BITS: usize = $($bits)*;
- }
- $crate::__doc_comment! {
- core::concat!(
- "Number of bytes used by an instance of [`", core::stringify!($name), "`]."
- ),
- pub const BYTES: usize = $($bits)* / 8;
- }
- $crate::__doc_comment! {
- core::concat!(
- "Maximum valid integer for [`", core::stringify!($name), "`]."
- ),
- pub const MAX: $type = $max;
- }
- }
- }
- };
-}
-
-/// Generates constructors for `$name`
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_field_ctors {
- ( $name:ident : $type:ty ) => {
- $crate::__doc_comment! {
- core::concat!(
- "Constructors for creating instances of [`", core::stringify!($name), "`]."
- ),
- impl $name {
- $crate::__doc_comment! {
- core::concat!(
- "Create a new instance of [`", core::stringify!($name), "`] ",
- "from a [`", core::stringify!($type), "`] value."
- ),
- pub fn new(value: $type) -> Self {
- Self(value)
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Create a new instance of [`", core::stringify!($name), "`] ",
- "from `0`."
- ),
- pub fn zeros() -> Self {
- Self(0)
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Create a new instance of [`", core::stringify!($name), "`] ",
- "from the maximum possible integer value."
- ),
- pub fn ones() -> Self {
- Self(Self::MAX)
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Create a new instance of [`", core::stringify!($name), "`] ",
- "from a binary string."
- ),
- pub fn from_binary_str(value: &str) -> Self {
- Self(<$type>::from_str_radix(value, 2).unwrap())
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Create a new instance of [`", core::stringify!($name), "`] ",
- "from a binary string."
- ),
- pub fn from_binary_string(value: String) -> Self {
- Self(<$type>::from_str_radix(value.as_str(), 2).unwrap())
- }
- }
- }
- }
- };
-}
-
-/// Generates getters for state fields in `$name`
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_field_state {
- ($name:ident : $type:ty) => {
- $crate::__doc_comment! {
- core::concat!(
- "Current state of this bitfield."
- ),
- impl $name {
- $crate::__doc_comment! {
- core::concat!(
- "Returns the current field value as a [`", core::stringify!($type), "`]"
- ),
- pub fn as_integer(&self) -> $type {
- self.0
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Returns the current field value as a binary formatted string."
- ),
- pub fn as_binary(&self) -> String {
- std::format!("{:0width$b}", self.0, width = Self::BITS)
- }
- }
- }
- }
- };
-}
-
-/// Generates getters by index for bit fields in `$name`
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_field_index_accessors {
- ($name:ident) => {
- $crate::__doc_comment! {
- core::concat!(
- "Field accessors by index for [`", core::stringify!($name), "`]."
- ),
- impl $name {
- $crate::__doc_comment! {
- core::concat!(
- "Returns the value of the bit at the supplied index as a boolean."
- ),
- pub fn get_index(&self, index: u8) -> bool {
- ((self.0 >> index) & 1) == 1
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Sets the value of the bit at the supplied index to `1`."
- ),
- pub fn set_index(&mut self, index: u8) {
- self.0 |= (1 << index);
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Sets the value of the bit at the supplied index to `0`."
- ),
- pub fn clear_index(&mut self, index: u8) {
- self.0 &= !(1 << index);
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Flips the value of the bit at the supplied index."
- ),
- pub fn toggle_index(&mut self, index: u8) {
- self.0 ^= (1 << index);
- }
- }
- }
- }
- };
-}
-
-/// Generates getters by flag for bit fields in `$name`
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_field_flag_accessors {
- ($name:ident $flag:ident $type:ty) => {
- $crate::__doc_comment! {
- core::concat!(
- "Named field accessors by [`", core::stringify!($flag), "`] for [`", core::stringify!($name), "`]."
- ),
- impl $name {
- $crate::__doc_comment! {
- core::concat!(
- "Returns the value of the bit at the supplied flag as a boolean."
- ),
- pub fn get(&self, flag: $flag) -> bool {
- ((self.0 >> (flag as $type)) & 1) == 1
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Sets the value of the bit at the supplied flag to `1`."
- ),
- pub fn set(&mut self, flag: $flag) -> &mut Self {
- self.0 |= (1 << (flag as $type));
- self
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Sets the value of the bit at the supplied flag to `0`."
- ),
- pub fn clear(&mut self, flag: $flag) -> &mut Self {
- self.0 &= !(1 << (flag as $type));
- self
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Flips the value of the bit at the supplied flag."
- ),
- pub fn toggle(&mut self, flag: $flag) -> &mut Self {
- self.0 ^= (1 << (flag as $type));
- self
- }
- }
- }
- }
- };
-}
-
-/// Generates combinator methods for `$name`
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_field_flag_combinators {
- ($name:ident) => {
- $crate::__doc_comment! {
- core::concat!(
- "Combinators for [`", core::stringify!($name), "`]."
- ),
- impl $name {
- $crate::__doc_comment! {
- core::concat!(
- "Returns a new [`", core::stringify!($name), "`]",
- "with ones for flags that do not match. ",
- "Does not consume `self`."
- ),
- pub fn diff(&self, other: Self) -> Self {
- Self(self.0 ^ other.0)
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Returns a new [`", core::stringify!($name), "`]",
- "with ones for flags that were set on either input. ",
- "Does not consume `self`."
- ),
- pub fn combine(&self, other: Self) -> Self {
- Self(self.0 | other.0)
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Returns a new [`", core::stringify!($name), "`]",
- "with ones for flags that were set on both inputs. ",
- "Does not consume `self`."
- ),
- pub fn intersect(&self, other: Self) -> Self {
- Self(self.0 & other.0)
- }
- }
- }
- }
- };
-}
-
-/// Generates conversion methods for `$name`
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_field_flag_converters {
- ($name:ident) => {
- $crate::__doc_comment! {
- core::concat!(
- "Conversion methods."
- ),
- impl $name {
- $crate::__doc_comment! {
- core::concat!(
- "Returns a new [`", core::stringify!($name), "`]",
- "with ones for flags that do not match. ",
- "Consumes `self`."
- ),
- pub fn into_diff(self, other: Self) -> Self {
- Self(self.0 ^ other.0)
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Returns a new [`", core::stringify!($name), "`]",
- "with ones for flags that were set on either input. ",
- "Consumes `self`."
- ),
- pub fn into_combined(self, other: Self) -> Self {
- Self(self.0 | other.0)
- }
- }
-
- $crate::__doc_comment! {
- core::concat!(
- "Returns a new [`", core::stringify!($name), "`]",
- "with ones for flags that were set on both inputs. ",
- "Consumes `self`."
- ),
- pub fn into_intersection(self, other: Self) -> Self {
- Self(self.0 & other.0)
- }
- }
- }
- }
- };
-}
-
-// -------------------------------------------------------------------------------------------------
-// Trait Implementations
-
-// Operators
-
-/// Generates a set of bitwise operators
-/// for a set of parameters
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! __impl_bitwise_operators {
-
- // Owned
- (
- [$flag:ty] for $dest:ident : ($self:ident $other:ident -> $output:ident)
- $( BitAnd => $bitand:block )?
- $( BitOr => $bitor:block )?
- $( BitXor => $bitxor:block )?
- $( BitAndAssign => $bitand_assign:block )?
- $( BitOrAssign => $bitor_assign:block )?
- $( BitXorAssign => $bitxor_assign:block )?
- ) => {
- $( __impl_operator! {BitAnd [$flag] bitand for $dest ($self $other -> $output) => $bitand} )?
- $( __impl_operator! {BitOr [$flag] bitor for $dest ($self $other -> $output) => $bitor} )?
- $( __impl_operator! {BitXor [$flag] bitxor for $dest ($self $other -> $output) => $bitxor} )?
-
- $( __impl_assign_operator! {BitAndAssign [$flag] bitand_assign for $dest ($self $other) => $bitand_assign} )?
- $( __impl_assign_operator! {BitOrAssign [$flag] bitor_assign for $dest ($self $other) => $bitor_assign} )?
- $( __impl_assign_operator! {BitXorAssign [$flag] bitxor_assign for $dest ($self $other) => $bitxor_assign} )?
- };
-
- // Reference
- (
- [$flag:ty] for & $dest:ident : ($self:ident $other:ident -> $output:ident)
- $( BitAnd => $bitand:block )?
- $( BitOr => $bitor:block )?
- $( BitXor => $bitxor:block )?
- ) => {
- $( __impl_operator! {BitAnd [$flag] bitand for & $dest ($self $other -> $output) => $bitand} )?
- $( __impl_operator! {BitOr [$flag] bitor for & $dest ($self $other -> $output) => $bitor} )?
- $( __impl_operator! {BitXor [$flag] bitxor for & $dest ($self $other -> $output) => $bitxor} )?
- };
-
- // Mutable Reference
- (
- [$flag:ty] for &mut $dest:ident : ($self:ident $other:ident -> $output:ident)
- $( BitAnd => $bitand:block )?
- $( BitOr => $bitor:block )?
- $( BitXor => $bitxor:block )?
- ) => {
- $( __impl_operator! {BitAnd [$flag] bitand for &mut $dest ($self $other -> $output) => $bitand} )?
- $( __impl_operator! {BitOr [$flag] bitor for &mut $dest ($self $other -> $output) => $bitor} )?
- $( __impl_operator! {BitXor [$flag] bitxor for &mut $dest ($self $other -> $output) => $bitxor} )?
- };
-}
-
-/// Generates a generic operator
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_operator {
-
- // Owned
- ( $op_type:ident [$rhs:ty] $op_lower:ident for $dest:ident ($self:ident $other:ident -> $output:ident) => $block:block ) => {
- impl std::ops::$op_type<$rhs> for $dest {
- type Output = $output;
- fn $op_lower($self, $other: $rhs) -> Self::Output $block
- }
- };
-
- // Reference
- ( $op_type:ident [$rhs:ty] $op_lower:ident for & $dest:ident ($self:ident $other:ident -> $output:ident) => $block:block ) => {
- impl std::ops::$op_type<$rhs> for &$dest {
- type Output = $output;
- fn $op_lower($self, $other: $rhs) -> Self::Output $block
- }
- };
-
- // Mutable Reference
- ( $op_type:ident [$rhs:ty] $op_lower:ident for &mut $dest:ident ($self:ident $other:ident -> $output:ident) => $block:block ) => {
- impl std::ops::$op_type<$rhs> for &mut $dest {
- type Output = $output;
- fn $op_lower($self, $other: $rhs) -> Self::Output $block
- }
- };
-}
-
-/// Generates a generic assign operator
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_assign_operator {
- ( $op_type:ident [$rhs:ty] $op_lower:ident for $dest:ident ($self:ident $other:ident) => $block:block ) => {
- impl std::ops::$op_type<$rhs> for $dest {
- fn $op_lower(&mut $self, $other: $rhs) $block
- }
- };
-}
-
-// Defaults
-
-/// Generates a [`Default`] implementation.
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_default {
- ($name:ident => $block:block) => {
- impl Default for $name {
- fn default() -> Self $block
- }
- };
-}
-
-// Converters
-
-/// Generates a [`From`] implementation.
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_from {
- ($(#[$doc:meta])* $from:ty as $to:ident ($arg:ident) => $block:block) => {
- $(#[$doc])*
- impl From<$from> for $to {
- fn from($arg: $from) -> $to $block
- }
- };
-}
-
-// Formatters
-
-/// Generates formatter implementations
-/// from a set of parameters.
-#[doc(hidden)]
-#[macro_export(local_inner_macros)]
-macro_rules! __impl_formatters {
- ($name:ident ($self:ident $f:ident) { $( $formatter:ident => $block:block )+ } ) => {
- $( __impl_formatter!($formatter for $name ($self $f) => $block); )+
- };
-}
-
-/// Generates a generic formatter implementation.
-#[doc(hidden)]
-#[macro_export]
-macro_rules! __impl_formatter {
- ($formatter:ident for $name:ident ($self:ident $f:ident) => $block:block) => {
- impl std::fmt::$formatter for $name {
- fn fmt(&$self, $f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result $block
- }
- };
-}
-
-// -------------------------------------------------------------------------------------------------
-// Example
-
-#[allow(dead_code)]
-#[allow(unused_variables)]
-#[cfg(doc)]
-pub mod examples {
- //! Examples of generated output using different configurations.
- //!
- //! __This module is only compiled with documentation builds
- //! and will not be available for import.__
- //!
- //! use the [`bitfield`] macro to generate a field struct and flag enum.
- //!
-
- #[allow(dead_code)]
- #[allow(unused_variables)]
- #[cfg(doc)]
- pub mod full_example {
- //! Example of generated output, using both a bit field and a flag enum.
- //!
- //! __This module is only compiled with documentation builds
- //! and will not be available for import.__
- //!
- //! use the [`bitfield`] macro to generate a field struct and flag enum.
- //!
- use super::*;
-
- bitfield! {
- /// Optional docstring for my example bit field.
- pub u8 ExampleField
- /// Optional docstring for my flag enum.
- ExampleFlags {
- /// Optional docstring for Flag0
- 0 : Flag0,
- /// Optional docstring for Flag1
- 1 : Flag1,
- /// Optional docstring for Flag2
- 2 : Flag2,
- /// Optional docstring for Flag3
- 3 : Flag3,
- /// Optional docstring for Flag4
- 4 : Flag4,
- /// Optional docstring for Flag5
- 5 : Flag5,
- /// Optional docstring for Flag6
- 6 : Flag6,
- /// Optional docstring for Flag7
- 7 : Flag7,
- }
- }
- }
-
- #[allow(dead_code)]
- #[allow(unused_variables)]
- #[cfg(doc)]
- pub mod flagless_example {
- //! Example of generated output, using only a bit field without a flag enum.
- //!
- //! __This module is only compiled with documentation builds
- //! and will not be available for import.__
- //!
- //! use the [`bitfield`] macro to generate a field struct and flag enum.
- //!
- use super::*;
-
- bitfield! {
- /// Optional docstring for my example bit field.
- pub u8 ExampleField
- }
- }
-}
-
-// -------------------------------------------------------------------------------------------------
-// Tests
-
-#[allow(dead_code)]
-#[allow(unused_variables)]
-#[cfg(test)]
-mod test {
- use super::*;
- use std::{u128, u16, u32, u64, usize};
-
- macro_rules! tests {
- ( $( $name:ident => $block:block )+ ) => {
- $(
- #[test]
- fn $name() $block
- )+
- };
- }
-
- bitfield! {
- /// My Test Thing
- u8 MyFieldU8
- MyFlagsU8 {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u16 MyFieldU16
- MyFlagsU16 {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u32 MyFieldU32
- MyFlagsU32 {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u64 MyFieldU64
- MyFlagsU64 {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
- 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
- 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
- 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u128 MyFieldU128
- MyFlagsU128 {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
- 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
- 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
- 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
- 64 : Flag64, 65 : Flag65, 66 : Flag66, 67 : Flag67, 68 : Flag68, 69 : Flag69, 70 : Flag70, 71 : Flag71,
- 72 : Flag72, 73 : Flag73, 74 : Flag74, 75 : Flag75, 76 : Flag76, 77 : Flag77, 78 : Flag78, 79 : Flag79,
- 80 : Flag80, 81 : Flag81, 82 : Flag82, 83 : Flag83, 84 : Flag84, 85 : Flag85, 86 : Flag86, 87 : Flag87,
- 88 : Flag88, 89 : Flag89, 90 : Flag90, 91 : Flag91, 92 : Flag92, 93 : Flag93, 94 : Flag94, 95 : Flag95,
- 96 : Flag96, 97 : Flag97, 98 : Flag98, 99 : Flag99, 100 : Flag100, 101 : Flag101, 102 : Flag102, 103 : Flag103,
- 104 : Flag104, 105 : Flag105, 106 : Flag106, 107 : Flag107, 108 : Flag108, 109 : Flag109, 110 : Flag110, 111 : Flag111,
- 112 : Flag112, 113 : Flag113, 114 : Flag114, 115 : Flag115, 116 : Flag116, 117 : Flag117, 118 : Flag118, 119 : Flag119,
- 120 : Flag120, 121 : Flag121, 122 : Flag122, 123 : Flag123, 124 : Flag124, 125 : Flag125, 126 : Flag126, 127 : Flag127,
- }
- }
-
- #[cfg(target_pointer_width = "64")]
- bitfield! {
- /// My Test Thing
- usize MyFieldUsize
- MyFlagsUsize {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
- 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
- 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
- 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
- }
- }
-
- #[cfg(target_pointer_width = "32")]
- bitfield! {
- /// My Test Thing
- usize MyFieldUsize
- MyFlagsUsize {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u8 MyFieldU8Nf
- MyFlagsU8Nf {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u16 MyFieldU16Nf
- MyFlagsU16Nf {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u32 MyFieldU32Nf
- MyFlagsU32Nf {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u64 MyFieldU64Nf
- MyFlagsU64Nf {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
- 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
- 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
- 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
- }
- }
-
- bitfield! {
- /// My Test Thing
- u128 MyFieldU128Nf
- MyFlagsU128Nf {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
- 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
- 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
- 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
- 64 : Flag64, 65 : Flag65, 66 : Flag66, 67 : Flag67, 68 : Flag68, 69 : Flag69, 70 : Flag70, 71 : Flag71,
- 72 : Flag72, 73 : Flag73, 74 : Flag74, 75 : Flag75, 76 : Flag76, 77 : Flag77, 78 : Flag78, 79 : Flag79,
- 80 : Flag80, 81 : Flag81, 82 : Flag82, 83 : Flag83, 84 : Flag84, 85 : Flag85, 86 : Flag86, 87 : Flag87,
- 88 : Flag88, 89 : Flag89, 90 : Flag90, 91 : Flag91, 92 : Flag92, 93 : Flag93, 94 : Flag94, 95 : Flag95,
- 96 : Flag96, 97 : Flag97, 98 : Flag98, 99 : Flag99, 100 : Flag100, 101 : Flag101, 102 : Flag102, 103 : Flag103,
- 104 : Flag104, 105 : Flag105, 106 : Flag106, 107 : Flag107, 108 : Flag108, 109 : Flag109, 110 : Flag110, 111 : Flag111,
- 112 : Flag112, 113 : Flag113, 114 : Flag114, 115 : Flag115, 116 : Flag116, 117 : Flag117, 118 : Flag118, 119 : Flag119,
- 120 : Flag120, 121 : Flag121, 122 : Flag122, 123 : Flag123, 124 : Flag124, 125 : Flag125, 126 : Flag126, 127 : Flag127,
- }
- }
-
- #[cfg(target_pointer_width = "64")]
- bitfield! {
- /// My Test Thing
- usize MyFieldUsizeNf
- MyFlagsUsizeNf {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
- 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
- 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
- 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
- }
- }
-
- #[cfg(target_pointer_width = "32")]
- bitfield! {
- /// My Test Thing
- usize MyFieldUsizeNf
- MyFlagsUsizeNf {
- 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
- 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
- 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
- 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
- }
- }
-
- const U8: u8 = 123;
- const B8: &str = "01111011";
- const U16: u16 = 51526;
- const B16: &str = "1100100101000110";
- const U32: u32 = 2828091834;
- const B32: &str = "10101000100100010100000110111010";
- const U64: u64 = 18325744043706550615;
- const B64: &str = "1111111001010010000111110001110100100001110111000000100101010111";
- const U128: u128 = 160140183460469230739687303714882104727;
- const B128: &str = "01111000011110011110000010100001011000111110000100101011010111011111111110000110011101100010110100100000110001101010110110010111";
-
- #[cfg(target_pointer_width = "64")]
- const USIZE: usize = 18325744043706550615;
- #[cfg(target_pointer_width = "64")]
- const BSIZE: &str = "1111111001010010000111110001110100100001110111000000100101010111";
-
- #[cfg(target_pointer_width = "32")]
- const USIZE: usize = 2828091834;
- #[cfg(target_pointer_width = "32")]
- const BSIZE: &str = "10101000100100010100000110111010";
-
- // constructors
- tests! {
- new_u8 => {
- MyFieldU8(U8);
- }
- new_u16 => {
- MyFieldU16(U16);
- }
- new_u32 => {
- MyFieldU32(U32);
- }
- new_u64 => {
- MyFieldU64(U64);
- }
- new_u128 => {
- MyFieldU128(U128);
- }
- new_usize => {
- MyFieldUsize(USIZE);
- }
- }
-
- // from binary str
- tests! {
- from_binary_str_u8 => {
- assert_eq!(MyFieldU8::from_binary_str(B8), MyFieldU8(U8));
- }
- from_binary_str_u16 => {
- assert_eq!(MyFieldU16::from_binary_str(B16), MyFieldU16(U16));
- }
- from_binary_str_u32 => {
- assert_eq!(MyFieldU32::from_binary_str(B32), MyFieldU32(U32));
- }
- from_binary_str_u64 => {
- assert_eq!(MyFieldU64::from_binary_str(B64), MyFieldU64(U64));
- }
- from_binary_str_u128 => {
- assert_eq!(MyFieldU128::from_binary_str(B128), MyFieldU128(U128));
- }
- from_binary_str_usize => {
- assert_eq!(MyFieldUsize::from_binary_str(BSIZE), MyFieldUsize(USIZE));
- }
- }
-
- // from binary string
- tests! {
- from_binary_string_u8 => {
- assert_eq!(MyFieldU8::from_binary_string(String::from(B8)), MyFieldU8(U8));
- }
- from_binary_string_u16 => {
- assert_eq!(MyFieldU16::from_binary_string(String::from(B16)), MyFieldU16(U16));
- }
- from_binary_string_u32 => {
- assert_eq!(MyFieldU32::from_binary_string(String::from(B32)), MyFieldU32(U32));
- }
- from_binary_string_u64 => {
- assert_eq!(MyFieldU64::from_binary_string(String::from(B64)), MyFieldU64(U64));
- }
- from_binary_string_u128 => {
- assert_eq!(MyFieldU128::from_binary_string(String::from(B128)), MyFieldU128(U128));
- }
- from_binary_string_usize => {
- assert_eq!(MyFieldUsize::from_binary_string(String::from(BSIZE)), MyFieldUsize(USIZE));
- }
- }
-
- // ones
- tests! {
- ones_u8 => {
- assert_eq!(MyFieldU8::ones(), MyFieldU8(u8::MAX));
- }
- ones_u16 => {
- assert_eq!(MyFieldU16::ones(), MyFieldU16(u16::MAX));
- }
- ones_u32 => {
- assert_eq!(MyFieldU32::ones(), MyFieldU32(u32::MAX));
- }
- ones_u64 => {
- assert_eq!(MyFieldU64::ones(), MyFieldU64(u64::MAX));
- }
- ones_u128 => {
- assert_eq!(MyFieldU128::ones(), MyFieldU128(u128::MAX));
- }
- ones_usize => {
- assert_eq!(MyFieldUsize::ones(), MyFieldUsize(usize::MAX));
- }
- }
-
- // zeros
- tests! {
- zeros_u8 => {
- assert_eq!(MyFieldU8::zeros(), MyFieldU8(0));
- }
- zeros_u16 => {
- assert_eq!(MyFieldU16::zeros(), MyFieldU16(0));
- }
- zeros_u32 => {
- assert_eq!(MyFieldU32::zeros(), MyFieldU32(0));
- }
- zeros_u64 => {
- assert_eq!(MyFieldU64::zeros(), MyFieldU64(0));
- }
- zeros_u128 => {
- assert_eq!(MyFieldU128::zeros(), MyFieldU128(0));
- }
- zeros_usize => {
- assert_eq!(MyFieldUsize::zeros(), MyFieldUsize(0));
- }
- }
-
- // defaults
- tests! {
- default_u8 => {
- assert_eq!(0, MyFieldU8::default().as_integer())
- }
- default_u16 => {
- assert_eq!(0, MyFieldU16::default().as_integer())
- }
- default_u32 => {
- assert_eq!(0, MyFieldU32::default().as_integer())
- }
- default_u64 => {
- assert_eq!(0, MyFieldU64::default().as_integer())
- }
- default_u128 => {
- assert_eq!(0, MyFieldU128::default().as_integer())
- }
- default_usize => {
- assert_eq!(0, MyFieldUsize::default().as_integer())
- }
- }
-
- // bit count
- tests! {
- bit_count_u8 => {
- let field = MyFieldU8(U8);
- assert_eq!(u8::BITS as usize, MyFieldU8::BITS)
- }
- bit_count_u16 => {
- let field = MyFieldU16(U16);
- assert_eq!(u16::BITS as usize, MyFieldU16::BITS)
- }
- bit_count_u32 => {
- let field = MyFieldU32(U32);
- assert_eq!(u32::BITS as usize, MyFieldU32::BITS)
- }
- bit_count_u64 => {
- let field = MyFieldU64(U64);
- assert_eq!(u64::BITS as usize, MyFieldU64::BITS)
- }
- bit_count_u128 => {
- let field = MyFieldU128(U128);
- assert_eq!(u128::BITS as usize, MyFieldU128::BITS)
- }
- bit_count_usize => {
- let field = MyFieldUsize(USIZE);
- assert_eq!(usize::BITS as usize, MyFieldUsize::BITS)
- }
- }
-
- // byte count
- tests! {
- byte_count_u8 => {
- let field = MyFieldU8(U8);
- assert_eq!(1, MyFieldU8::BYTES)
- }
- byte_count_u16 => {
- let field = MyFieldU16(U16);
- assert_eq!(2, MyFieldU16::BYTES)
- }
- byte_count_u32 => {
- let field = MyFieldU32(U32);
- assert_eq!(4, MyFieldU32::BYTES)
- }
- byte_count_u64 => {
- let field = MyFieldU64(U64);
- assert_eq!(8, MyFieldU64::BYTES)
- }
- byte_count_u128 => {
- let field = MyFieldU128(U128);
- assert_eq!(16, MyFieldU128::BYTES)
- }
- byte_count_usize => {
- let field = MyFieldUsize(USIZE);
- assert_eq!((usize::BITS as usize) / 8, MyFieldUsize::BYTES)
- }
- }
-
- // integer value
- tests! {
- integer_u8 => {
- let field = MyFieldU8(U8);
- assert_eq!(U8, field.as_integer())
- }
- integer_u16 => {
- let field = MyFieldU16(U16);
- assert_eq!(U16, field.as_integer())
- }
- integer_u32 => {
- let field = MyFieldU32(U32);
- assert_eq!(U32, field.as_integer())
- }
- integer_u64 => {
- let field = MyFieldU64(U64);
- assert_eq!(U64, field.as_integer())
- }
- integer_u128 => {
- let field = MyFieldU128(U128);
- assert_eq!(U128, field.as_integer())
- }
- integer_usize => {
- let field = MyFieldUsize(USIZE);
- assert_eq!(USIZE, field.as_integer())
- }
- }
-
- // binary value
- tests! {
- binary_u8 => {
- let field = MyFieldU8(U8);
- assert_eq!(B8, field.as_binary())
- }
- binary_u16 => {
- let field = MyFieldU16(U16);
- assert_eq!(B16, field.as_binary())
- }
- binary_u32 => {
- let field = MyFieldU32(U32);
- assert_eq!(B32, field.as_binary())
- }
- binary_u64 => {
- let field = MyFieldU64(U64);
- assert_eq!(B64, field.as_binary())
- }
- binary_u128 => {
- let field = MyFieldU128(U128);
- assert_eq!(B128, field.as_binary())
- }
- binary_usize => {
- let field = MyFieldUsize(USIZE);
- assert_eq!(BSIZE, field.as_binary())
- }
- }
-
- // get index
- tests! {
- get_index_u8 => {
- let field = MyFieldU8(U8);
- for (index, char) in B8.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8))
- } else if char == '0' {
- assert!(!field.get_index(index as u8))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_index_u16 => {
- let field = MyFieldU16(U16);
- for (index, char) in B16.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8))
- } else if char == '0' {
- assert!(!field.get_index(index as u8))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_index_u32 => {
- let field = MyFieldU32(U32);
- for (index, char) in B32.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8))
- } else if char == '0' {
- assert!(!field.get_index(index as u8))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_index_u64 => {
- let field = MyFieldU64(U64);
- for (index, char) in B64.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8))
- } else if char == '0' {
- assert!(!field.get_index(index as u8))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_index_u128 => {
- let field = MyFieldU128(U128);
- for (index, char) in B128.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8))
- } else if char == '0' {
- assert!(!field.get_index(index as u8))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_index_usize => {
- let field = MyFieldUsize(USIZE);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8))
- } else if char == '0' {
- assert!(!field.get_index(index as u8))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- }
-
- // set index
- tests! {
- set_index_u8 => {
- let mut field = MyFieldU8(0);
- for (index, char) in B8.chars().rev().enumerate() {
- field.set_index(index as u8);
- for (s_index, _char) in B8.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_index_u16 => {
- let mut field = MyFieldU16(0);
- for (index, char) in B16.chars().rev().enumerate() {
- field.set_index(index as u8);
- for (s_index, _char) in B16.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_index_u32 => {
- let mut field = MyFieldU32(0);
- for (index, char) in B32.chars().rev().enumerate() {
- field.set_index(index as u8);
- for (s_index, _char) in B32.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_index_u64 => {
- let mut field = MyFieldU64(0);
- for (index, char) in B64.chars().rev().enumerate() {
- field.set_index(index as u8);
- for (s_index, _char) in B64.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_index_u128 => {
- let mut field = MyFieldU128(0);
- for (index, char) in B128.chars().rev().enumerate() {
- field.set_index(index as u8);
- for (s_index, _char) in B128.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_index_usize => {
- let mut field = MyFieldUsize(0);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- field.set_index(index as u8);
- for (s_index, _char) in BSIZE.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- }
-
- // clear index
- tests! {
- clear_index_u8 => {
- let mut field = MyFieldU8(u8::MAX);
- for (index, char) in B8.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear_index(index as u8);
- for (s_index, _char) in B8.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_index_u16 => {
- let mut field = MyFieldU16(u16::MAX);
- for (index, char) in B16.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear_index(index as u8);
- for (s_index, _char) in B16.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_index_u32 => {
- let mut field = MyFieldU32(u32::MAX);
- for (index, char) in B32.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear_index(index as u8);
- for (s_index, _char) in B32.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_index_u64 => {
- let mut field = MyFieldU64(u64::MAX);
- for (index, char) in B64.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear_index(index as u8);
- for (s_index, _char) in B64.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_index_u128 => {
- let mut field = MyFieldU128(u128::MAX);
- for (index, char) in B128.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear_index(index as u8);
- for (s_index, _char) in B128.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_index_usize => {
- let mut field = MyFieldUsize(usize::MAX);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear_index(index as u8);
- for (s_index, _char) in BSIZE.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- }
-
- // toggle index
- tests! {
- toggle_index_u8 => {
- let mut field = MyFieldU8(U8);
- for (index, char) in B8.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string");
- }
- }
- }
- toggle_index_u16 => {
- let mut field = MyFieldU16(U16);
- for (index, char) in B16.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_index_u32 => {
- let mut field = MyFieldU32(U32);
- for (index, char) in B32.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_index_u64 => {
- let mut field = MyFieldU64(U64);
- for (index, char) in B64.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_index_u128 => {
- let mut field = MyFieldU128(U128);
- for (index, char) in B128.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_index_usize => {
- let mut field = MyFieldUsize(USIZE);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle_index(index as u8);
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- }
-
- // get
- tests! {
- get_u8 => {
- let field = MyFieldU8(U8);
- for (index, char) in B8.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get(MyFlagsU8::from(index as u8)))
- } else if char == '0' {
- assert!(!field.get(MyFlagsU8::from(index as u8)))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_u16 => {
- let field = MyFieldU16(U16);
- for (index, char) in B16.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get(MyFlagsU16::from(index as u8)))
- } else if char == '0' {
- assert!(!field.get(MyFlagsU16::from(index as u8)))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_u32 => {
- let field = MyFieldU32(U32);
- for (index, char) in B32.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get(MyFlagsU32::from(index as u8)))
- } else if char == '0' {
- assert!(!field.get(MyFlagsU32::from(index as u8)))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_u64 => {
- let field = MyFieldU64(U64);
- for (index, char) in B64.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get(MyFlagsU64::from(index as u8)))
- } else if char == '0' {
- assert!(!field.get(MyFlagsU64::from(index as u8)))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_u128 => {
- let field = MyFieldU128(U128);
- for (index, char) in B128.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get(MyFlagsU128::from(index as u8)))
- } else if char == '0' {
- assert!(!field.get(MyFlagsU128::from(index as u8)))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- get_usize => {
- let field = MyFieldUsize(USIZE);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get(MyFlagsUsize::from(index as u8)))
- } else if char == '0' {
- assert!(!field.get(MyFlagsUsize::from(index as u8)))
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- }
-
- // set
- tests! {
- set_u8 => {
- let mut field = MyFieldU8(0);
- for (index, char) in B8.chars().rev().enumerate() {
- field.set(MyFlagsU8::from(index as u8));
- for (s_index, _char) in B8.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_u16 => {
- let mut field = MyFieldU16(0);
- for (index, char) in B16.chars().rev().enumerate() {
- field.set(MyFlagsU16::from(index as u8));
- for (s_index, _char) in B16.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_u32 => {
- let mut field = MyFieldU32(0);
- for (index, char) in B32.chars().rev().enumerate() {
- field.set(MyFlagsU32::from(index as u8));
- for (s_index, _char) in B32.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_u64 => {
- let mut field = MyFieldU64(0);
- for (index, char) in B64.chars().rev().enumerate() {
- field.set(MyFlagsU64::from(index as u8));
- for (s_index, _char) in B64.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_u128 => {
- let mut field = MyFieldU128(0);
- for (index, char) in B128.chars().rev().enumerate() {
- field.set(MyFlagsU128::from(index as u8));
- for (s_index, _char) in B128.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- set_usize => {
- let mut field = MyFieldUsize(0);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- field.set(MyFlagsUsize::from(index as u8));
- for (s_index, _char) in BSIZE.chars().rev().enumerate() {
- if s_index <= index {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- }
-
- // clear
- tests! {
- clear_u8 => {
- let mut field = MyFieldU8(u8::MAX);
- for (index, char) in B8.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear(MyFlagsU8::from(index as u8));
- for (s_index, _char) in B8.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_u16 => {
- let mut field = MyFieldU16(u16::MAX);
- for (index, char) in B16.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear(MyFlagsU16::from(index as u8));
- for (s_index, _char) in B16.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_u32 => {
- let mut field = MyFieldU32(u32::MAX);
- for (index, char) in B32.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear(MyFlagsU32::from(index as u8));
- for (s_index, _char) in B32.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_u64 => {
- let mut field = MyFieldU64(u64::MAX);
- for (index, char) in B64.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear(MyFlagsU64::from(index as u8));
- for (s_index, _char) in B64.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_u128 => {
- let mut field = MyFieldU128(u128::MAX);
- for (index, char) in B128.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear(MyFlagsU128::from(index as u8));
- for (s_index, _char) in B128.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- clear_usize => {
- let mut field = MyFieldUsize(usize::MAX);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- assert!(field.get_index(index as u8), "{:#?}", field);
- field.clear(MyFlagsUsize::from(index as u8));
- for (s_index, _char) in BSIZE.chars().rev().enumerate() {
- if s_index <= index {
- assert!(!field.get_index(s_index as u8), "{:#?}", field);
- } else {
- assert!(field.get_index(s_index as u8), "{:#?}", field);
- }
- }
- }
- }
- }
-
- // toggle
- tests! {
- toggle_u8 => {
- let mut field = MyFieldU8(U8);
- for (index, char) in B8.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle(MyFlagsU8::from(index as u8));
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle(MyFlagsU8::from(index as u8));
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string");
- }
- }
- }
- toggle_u16 => {
- let mut field = MyFieldU16(U16);
- for (index, char) in B16.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle(MyFlagsU16::from(index as u8));
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle(MyFlagsU16::from(index as u8));
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_u32 => {
- let mut field = MyFieldU32(U32);
- for (index, char) in B32.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle(MyFlagsU32::from(index as u8));
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle(MyFlagsU32::from(index as u8));
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_u64 => {
- let mut field = MyFieldU64(U64);
- for (index, char) in B64.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle(MyFlagsU64::from(index as u8));
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle(MyFlagsU64::from(index as u8));
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_u128 => {
- let mut field = MyFieldU128(U128);
- for (index, char) in B128.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle(MyFlagsU128::from(index as u8));
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle(MyFlagsU128::from(index as u8));
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- toggle_usize => {
- let mut field = MyFieldUsize(USIZE);
- for (index, char) in BSIZE.chars().rev().enumerate() {
- if char == '1' {
- assert!(field.get_index(index as u8));
- field.toggle(MyFlagsUsize::from(index as u8));
- assert!(!field.get_index(index as u8));
- } else if char == '0' {
- assert!(!field.get_index(index as u8));
- field.toggle(MyFlagsUsize::from(index as u8));
- assert!(field.get_index(index as u8));
- } else {
- panic!("invalid char in binary string")
- }
- }
- }
- }
-
- // diff
- tests! {
- diff_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.diff(reversed);
- assert_eq!("10100101", out.as_binary());
- assert_eq!(165, out.as_integer());
- }
- diff_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.diff(reversed);
- assert_eq!("1010101111010101", out.as_binary());
- assert_eq!(43989, out.as_integer());
- }
- diff_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.diff(reversed);
- assert_eq!("11110101000100111100100010101111", out.as_binary());
- assert_eq!(4111714479, out.as_integer());
- }
- diff_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.diff(reversed);
- assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", out.as_binary());
- assert_eq!(1495798268358312744, out.as_integer());
- }
- diff_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.diff(reversed);
- assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", out.as_binary());
- assert_eq!(193799958082971305581995159990093034377, out.as_integer());
- }
- // diff_usize => {
- // let field = MyFieldUsize(USIZE);
- // }
- }
-
- // combine
- tests! {
- combine_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.combine(reversed);
- assert_eq!("11111111", out.as_binary());
- assert_eq!(255, out.as_integer());
- }
- combine_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.combine(reversed);
- assert_eq!("1110101111010111", out.as_binary());
- assert_eq!(60375, out.as_integer());
- }
- combine_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.combine(reversed);
- assert_eq!("11111101100100111100100110111111", out.as_binary());
- assert_eq!(4254321087, out.as_integer());
- }
- combine_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.combine(reversed);
- assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", out.as_binary());
- assert_eq!(18361808577405668223, out.as_integer());
- }
- combine_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.combine(reversed);
- assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", out.as_binary());
- assert_eq!(332296039312012448238196841470979719071, out.as_integer());
- }
- // combine_usize => {
- // let field = MyFieldUsize(USIZE);
- // }
- }
-
- // intersect
- tests! {
- intersect_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.intersect(reversed);
- assert_eq!("01011010", out.as_binary());
- assert_eq!(90, out.as_integer());
- }
- intersect_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.intersect(reversed);
- assert_eq!("0100000000000010", out.as_binary());
- assert_eq!(16386, out.as_integer());
- }
- intersect_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.intersect(reversed);
- assert_eq!("00001000100000000000000100010000", out.as_binary());
- assert_eq!(142606608, out.as_integer());
- }
- intersect_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.intersect(reversed);
- assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", out.as_binary());
- assert_eq!(16866010309047355479, out.as_integer());
- }
- intersect_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.intersect(reversed);
- assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", out.as_binary());
- assert_eq!(138496081229041142656201681480886684694, out.as_integer());
- }
- // intersect_usize => {
- // let field = MyFieldUsize(USIZE);
- // }
- }
-
- // into diff
- tests! {
- into_diff_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_diff(reversed);
- assert_eq!("10100101", out.as_binary());
- assert_eq!(165, out.as_integer());
- }
- into_diff_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_diff(reversed);
- assert_eq!("1010101111010101", out.as_binary());
- assert_eq!(43989, out.as_integer());
- }
- into_diff_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_diff(reversed);
- assert_eq!("11110101000100111100100010101111", out.as_binary());
- assert_eq!(4111714479, out.as_integer());
- }
- into_diff_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_diff(reversed);
- assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", out.as_binary());
- assert_eq!(1495798268358312744, out.as_integer());
- }
- into_diff_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_diff(reversed);
- assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", out.as_binary());
- assert_eq!(193799958082971305581995159990093034377, out.as_integer());
- }
- // into_diff_usize => {
- // let field = MyFieldUsize(USIZE);
- // }
- }
-
- // into combined
- tests! {
- into_combined_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_combined(reversed);
- assert_eq!("11111111", out.as_binary());
- assert_eq!(255, out.as_integer());
- }
- into_combined_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_combined(reversed);
- assert_eq!("1110101111010111", out.as_binary());
- assert_eq!(60375, out.as_integer());
- }
- into_combined_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_combined(reversed);
- assert_eq!("11111101100100111100100110111111", out.as_binary());
- assert_eq!(4254321087, out.as_integer());
- }
- into_combined_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_combined(reversed);
- assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", out.as_binary());
- assert_eq!(18361808577405668223, out.as_integer());
- }
- into_combined_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_combined(reversed);
- assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", out.as_binary());
- assert_eq!(332296039312012448238196841470979719071, out.as_integer());
- }
- // into_combined_usize => {
- // let field = MyFieldUsize(USIZE);
- // }
- }
-
- // into intersection
- tests! {
- into_intersection_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_intersection(reversed);
- assert_eq!("01011010", out.as_binary());
- assert_eq!(90, out.as_integer());
- }
- into_intersection_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_intersection(reversed);
- assert_eq!("0100000000000010", out.as_binary());
- assert_eq!(16386, out.as_integer());
- }
- into_intersection_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_intersection(reversed);
- assert_eq!("00001000100000000000000100010000", out.as_binary());
- assert_eq!(142606608, out.as_integer());
- }
- into_intersection_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_intersection(reversed);
- assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", out.as_binary());
- assert_eq!(16866010309047355479, out.as_integer());
- }
- into_intersection_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field.into_intersection(reversed);
- assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", out.as_binary());
- assert_eq!(138496081229041142656201681480886684694, out.as_integer());
- }
- // into_intersection_usize => {
- // let field = MyFieldUsize(USIZE);
- // }
- }
-
- // field from flag
- tests! {
- field_from_flag_u8 => {
- for index in 0..u8::BITS {
- let flag = MyFlagsU8::from(index as u8);
- let field = MyFieldU8::from(flag);
- assert_eq!(MyFieldU8(0u8 | (1 << index)), field)
- }
- }
- field_from_flag_u16 => {
- for index in 0..u16::BITS {
- let flag = MyFlagsU16::from(index as u8);
- let field = MyFieldU16::from(flag);
- assert_eq!(MyFieldU16(0u16 | (1 << index)), field)
- }
- }
- field_from_flag_u32 => {
- for index in 0..u32::BITS {
- let flag = MyFlagsU32::from(index as u8);
- let field = MyFieldU32::from(flag);
- assert_eq!(MyFieldU32(0u32 | (1 << index)), field)
- }
- }
- field_from_flag_u64 => {
- for index in 0..u64::BITS {
- let flag = MyFlagsU64::from(index as u8);
- let field = MyFieldU64::from(flag);
- assert_eq!(MyFieldU64(0u64 | (1 << index)), field)
- }
- }
- field_from_flag_u128 => {
- for index in 0..u128::BITS {
- let flag = MyFlagsU128::from(index as u8);
- let field = MyFieldU128::from(flag);
- assert_eq!(MyFieldU128(0u128 | (1 << index)), field)
- }
- }
- field_from_flag_usize => {
- for index in 0..usize::BITS {
- let flag = MyFlagsUsize::from(index as u8);
- let field = MyFieldUsize::from(flag);
- assert_eq!(MyFieldUsize(0usize | (1 << index)), field)
- }
- }
- }
-
- // $name & $name
- tests! {
- bitwise_name_and_name_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field & reversed;
- assert_eq!("01011010", out.as_binary());
- assert_eq!(90, out.as_integer());
- }
- bitwise_name_and_name_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field & reversed;
- assert_eq!("0100000000000010", out.as_binary());
- assert_eq!(16386, out.as_integer());
- }
- bitwise_name_and_name_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field & reversed;
- assert_eq!("00001000100000000000000100010000", out.as_binary());
- assert_eq!(142606608, out.as_integer());
- }
- bitwise_name_and_name_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field & reversed;
- assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", out.as_binary());
- assert_eq!(16866010309047355479, out.as_integer());
- }
- bitwise_name_and_name_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field & reversed;
- assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", out.as_binary());
- assert_eq!(138496081229041142656201681480886684694, out.as_integer());
- }
- // bitwise_name_and_name_usize => {
- //
- // }
- }
-
- // $name | $name
- tests! {
- bitwise_name_or_name_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field | reversed;
- assert_eq!("11111111", out.as_binary());
- assert_eq!(255, out.as_integer());
- }
- bitwise_name_or_name_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field | reversed;
- assert_eq!("1110101111010111", out.as_binary());
- assert_eq!(60375, out.as_integer());
- }
- bitwise_name_or_name_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field | reversed;
- assert_eq!("11111101100100111100100110111111", out.as_binary());
- assert_eq!(4254321087, out.as_integer());
- }
- bitwise_name_or_name_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field | reversed;
- assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", out.as_binary());
- assert_eq!(18361808577405668223, out.as_integer());
- }
- bitwise_name_or_name_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field | reversed;
- assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", out.as_binary());
- assert_eq!(332296039312012448238196841470979719071, out.as_integer());
- }
- // bitwise_name_or_name_usize => {
- //
- // }
- }
-
- // $name ^ $name
- tests! {
- bitwise_name_xor_name_u8 => {
- let field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field ^ reversed;
- assert_eq!("10100101", out.as_binary());
- assert_eq!(165, out.as_integer());
- }
- bitwise_name_xor_name_u16 => {
- let field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field ^ reversed;
- assert_eq!("1010101111010101", out.as_binary());
- assert_eq!(43989, out.as_integer());
- }
- bitwise_name_xor_name_u32 => {
- let field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field ^ reversed;
- assert_eq!("11110101000100111100100010101111", out.as_binary());
- assert_eq!(4111714479, out.as_integer());
- }
- bitwise_name_xor_name_u64 => {
- let field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field ^ reversed;
- assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", out.as_binary());
- assert_eq!(1495798268358312744, out.as_integer());
- }
- bitwise_name_xor_name_u128 => {
- let field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- let out = field ^ reversed;
- assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", out.as_binary());
- assert_eq!(193799958082971305581995159990093034377, out.as_integer());
- }
- // bitwise_name_xor_name_usize => {
- //
- // }
- }
-
- // $name &= $name
- tests! {
- bitwise_name_and_assign_name_u8 => {
- let mut field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field &= reversed;
- assert_eq!("01011010", field.as_binary());
- assert_eq!(90, field.as_integer());
- }
- bitwise_name_and_assign_name_u16 => {
- let mut field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field &= reversed;
- assert_eq!("0100000000000010", field.as_binary());
- assert_eq!(16386, field.as_integer());
- }
- bitwise_name_and_assign_name_u32 => {
- let mut field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field &= reversed;
- assert_eq!("00001000100000000000000100010000", field.as_binary());
- assert_eq!(142606608, field.as_integer());
- }
- bitwise_name_and_assign_name_u64 => {
- let mut field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field &= reversed;
- assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", field.as_binary());
- assert_eq!(16866010309047355479, field.as_integer());
- }
- bitwise_name_and_assign_name_u128 => {
- let mut field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field &= reversed;
- assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", field.as_binary());
- assert_eq!(138496081229041142656201681480886684694, field.as_integer());
- }
- // bitwise_name_and_assign_name_usize => {
- //
- // }
- }
-
- // $name |= $name
- tests! {
- bitwise_name_or_assign_name_u8 => {
- let mut field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field |= reversed;
- assert_eq!("11111111", field.as_binary());
- assert_eq!(255, field.as_integer());
- }
- bitwise_name_or_assign_name_u16 => {
- let mut field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field |= reversed;
- assert_eq!("1110101111010111", field.as_binary());
- assert_eq!(60375, field.as_integer());
- }
- bitwise_name_or_assign_name_u32 => {
- let mut field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field |= reversed;
- assert_eq!("11111101100100111100100110111111", field.as_binary());
- assert_eq!(4254321087, field.as_integer());
- }
- bitwise_name_or_assign_name_u64 => {
- let mut field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field |= reversed;
- assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", field.as_binary());
- assert_eq!(18361808577405668223, field.as_integer());
- }
- bitwise_name_or_assign_name_u128 => {
- let mut field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field |= reversed;
- assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", field.as_binary());
- assert_eq!(332296039312012448238196841470979719071, field.as_integer());
- }
- // bitwise_name_or_assign_name_usize => {
- //
- // }
- }
-
- // $name ^= $name
- tests! {
- bitwise_name_xor_assign_name_u8 => {
- let mut field = MyFieldU8(U8);
- let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field ^= reversed;
- assert_eq!("10100101", field.as_binary());
- assert_eq!(165, field.as_integer());
- }
- bitwise_name_xor_assign_name_u16 => {
- let mut field = MyFieldU16(U16);
- let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field ^= reversed;
- assert_eq!("1010101111010101", field.as_binary());
- assert_eq!(43989, field.as_integer());
- }
- bitwise_name_xor_assign_name_u32 => {
- let mut field = MyFieldU32(U32);
- let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field ^= reversed;
- assert_eq!("11110101000100111100100010101111", field.as_binary());
- assert_eq!(4111714479, field.as_integer());
- }
- bitwise_name_xor_assign_name_u64 => {
- let mut field = MyFieldU64(U64);
- let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field ^= reversed;
- assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", field.as_binary());
- assert_eq!(1495798268358312744, field.as_integer());
- }
- bitwise_name_xor_assign_name_u128 => {
- let mut field = MyFieldU128(U128);
- let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
- field ^= reversed;
- assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", field.as_binary());
- assert_eq!(193799958082971305581995159990093034377, field.as_integer());
- }
- // bitwise_name_xor_assign_name_usize => {
- //
- // }
- }
-
- // $name & $flag
- tests! {
- bitwise_name_and_flag_u8 => {
- for index in 0..u8::BITS {
- let mask = MyFieldU8(u8::MAX) & MyFlagsU8::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_flag_u16 => {
- for index in 0..u16::BITS {
- let mask = MyFieldU16(u16::MAX) & MyFlagsU16::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_flag_u32 => {
- for index in 0..u32::BITS {
- let mask = MyFieldU32(u32::MAX) & MyFlagsU32::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_flag_u64 => {
- for index in 0..u64::BITS {
- let mask = MyFieldU64(u64::MAX) & MyFlagsU64::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_flag_u128 => {
- for index in 0..u128::BITS {
- let mask = MyFieldU128(u128::MAX) & MyFlagsU128::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- // bitwise_name_and_flag_usize => {
- //
- // }
- }
-
- // $name | $flag
- tests! {
- bitwise_name_or_flag_u8 => {
- for index in 0..u8::BITS {
- let mask = MyFieldU8(0) | MyFlagsU8::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_flag_u16 => {
- for index in 0..u16::BITS {
- let mask = MyFieldU16(0) | MyFlagsU16::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_flag_u32 => {
- for index in 0..u32::BITS {
- let mask = MyFieldU32(0) | MyFlagsU32::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_flag_u64 => {
- for index in 0..u64::BITS {
- let mask = MyFieldU64(0) | MyFlagsU64::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_flag_u128 => {
- for index in 0..u128::BITS {
- let mask = MyFieldU128(0) | MyFlagsU128::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- // bitwise_name_or_flag_usize => {
- //
- // }
- }
-
- // $name ^ $flag
- tests! {
- bitwise_name_xor_flag_u8 => {
- for index in 0..u8::BITS {
- let mask = MyFieldU8(0) ^ MyFlagsU8::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_flag_u16 => {
- for index in 0..u16::BITS {
- let mask = MyFieldU16(0) ^ MyFlagsU16::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_flag_u32 => {
- for index in 0..u32::BITS {
- let mask = MyFieldU32(0) ^ MyFlagsU32::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_flag_u64 => {
- for index in 0..u64::BITS {
- let mask = MyFieldU64(0) ^ MyFlagsU64::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_flag_u128 => {
- for index in 0..u128::BITS {
- let mask = MyFieldU128(0) ^ MyFlagsU128::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- // bitwise_name_xor_flag_usize => {
- //
- // }
- }
-
- // $name &= $flag
- tests! {
- bitwise_name_and_assign_flag_u8 => {
- for index in 0..u8::BITS {
- let mut mask = MyFieldU8(u8::MAX);
- mask &= MyFlagsU8::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_assign_flag_u16 => {
- for index in 0..u16::BITS {
- let mut mask = MyFieldU16(u16::MAX);
- mask &= MyFlagsU16::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_assign_flag_u32 => {
- for index in 0..u32::BITS {
- let mut mask = MyFieldU32(u32::MAX);
- mask &= MyFlagsU32::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_assign_flag_u64 => {
- for index in 0..u64::BITS {
- let mut mask = MyFieldU64(u64::MAX);
- mask &= MyFlagsU64::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_and_assign_flag_u128 => {
- for index in 0..u128::BITS {
- let mut mask = MyFieldU128(u128::MAX);
- mask &= MyFlagsU128::from(index as u8);
- assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
- }
- }
- // bitwise_name_and_assign_flag_usize => {
- //
- // }
- }
-
- // $name |= $flag
- tests! {
- bitwise_name_or_assign_flag_u8 => {
- for index in 0..u8::BITS {
- let mut mask = MyFieldU8(0);
- mask |= MyFlagsU8::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_assign_flag_u16 => {
- for index in 0..u16::BITS {
- let mut mask = MyFieldU16(0);
- mask |= MyFlagsU16::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_assign_flag_u32 => {
- for index in 0..u32::BITS {
- let mut mask = MyFieldU32(0);
- mask |= MyFlagsU32::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_assign_flag_u64 => {
- for index in 0..u64::BITS {
- let mut mask = MyFieldU64(0);
- mask |= MyFlagsU64::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_or_assign_flag_u128 => {
- for index in 0..u128::BITS {
- let mut mask = MyFieldU128(0);
- mask |= MyFlagsU128::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- // bitwise_name_or_assign_flag_usize => {
- //
- // }
- }
-
- // $name ^= $flag
- tests! {
- bitwise_name_xor_assign_flag_u8 => {
- for index in 0..u8::BITS {
- let mut mask = MyFieldU8(0);
- mask ^= MyFlagsU8::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_assign_flag_u16 => {
- for index in 0..u16::BITS {
- let mut mask = MyFieldU16(0);
- mask ^= MyFlagsU16::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_assign_flag_u32 => {
- for index in 0..u32::BITS {
- let mut mask = MyFieldU32(0);
- mask ^= MyFlagsU32::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_assign_flag_u64 => {
- for index in 0..u64::BITS {
- let mut mask = MyFieldU64(0);
- mask ^= MyFlagsU64::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- bitwise_name_xor_assign_flag_u128 => {
- for index in 0..u128::BITS {
- let mut mask = MyFieldU128(0);
- mask ^= MyFlagsU128::from(index as u8);
- assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
- }
- }
- // bitwise_name_xor_assign_flag_usize => {
- //
- // }
- }
-
- // $flag & $flag
- tests! {
- bitwise_flag_and_flag_u8 => {
- for index_a in 0..u8::BITS {
- let a = MyFlagsU8::from(index_a as u8);
- for index_b in 0..u8::BITS {
- let b = MyFlagsU8::from(index_b as u8);
- assert_eq!(MyFieldU8(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
- }
- }
- }
- bitwise_flag_and_flag_u16 => {
- for index_a in 0..u16::BITS {
- let a = MyFlagsU16::from(index_a as u8);
- for index_b in 0..u16::BITS {
- let b = MyFlagsU16::from(index_b as u8);
- assert_eq!(MyFieldU16(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
- }
- }
- }
- bitwise_flag_and_flag_u32 => {
- for index_a in 0..u32::BITS {
- let a = MyFlagsU32::from(index_a as u8);
- for index_b in 0..u32::BITS {
- let b = MyFlagsU32::from(index_b as u8);
- assert_eq!(MyFieldU32(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
- }
- }
- }
- bitwise_flag_and_flag_u64 => {
- for index_a in 0..u64::BITS {
- let a = MyFlagsU64::from(index_a as u8);
- for index_b in 0..u64::BITS {
- let b = MyFlagsU64::from(index_b as u8);
- assert_eq!(MyFieldU64(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
- }
- }
- }
- bitwise_flag_and_flag_u128 => {
- for index_a in 0..u128::BITS {
- let a = MyFlagsU128::from(index_a as u8);
- for index_b in 0..u128::BITS {
- let b = MyFlagsU128::from(index_b as u8);
- assert_eq!(MyFieldU128(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
- }
- }
- }
- // bitwise_flag_and_flag_usize => {
- //
- // }
- }
-
- // $flag | $flag
- tests! {
- bitwise_flag_or_flag_u8 => {
- for index_a in 0..u8::BITS {
- let a = MyFlagsU8::from(index_a as u8);
- for index_b in 0..u8::BITS {
- let b = MyFlagsU8::from(index_b as u8);
- assert_eq!(MyFieldU8(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
- }
- }
- }
- bitwise_flag_or_flag_u16 => {
- for index_a in 0..u16::BITS {
- let a = MyFlagsU16::from(index_a as u8);
- for index_b in 0..u16::BITS {
- let b = MyFlagsU16::from(index_b as u8);
- assert_eq!(MyFieldU16(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
- }
- }
- }
- bitwise_flag_or_flag_u32 => {
- for index_a in 0..u32::BITS {
- let a = MyFlagsU32::from(index_a as u8);
- for index_b in 0..u32::BITS {
- let b = MyFlagsU32::from(index_b as u8);
- assert_eq!(MyFieldU32(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
- }
- }
- }
- bitwise_flag_or_flag_u64 => {
- for index_a in 0..u64::BITS {
- let a = MyFlagsU64::from(index_a as u8);
- for index_b in 0..u64::BITS {
- let b = MyFlagsU64::from(index_b as u8);
- assert_eq!(MyFieldU64(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
- }
- }
- }
- bitwise_flag_or_flag_u128 => {
- for index_a in 0..u128::BITS {
- let a = MyFlagsU128::from(index_a as u8);
- for index_b in 0..u128::BITS {
- let b = MyFlagsU128::from(index_b as u8);
- assert_eq!(MyFieldU128(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
- }
- }
- }
- // bitwise_flag_or_flag_usize => {
- //
- // }
- }
-
- // $flag ^ $flag
- tests! {
- bitwise_flag_xor_flag_u8 => {
- for index_a in 0..u8::BITS {
- let a = MyFlagsU8::from(index_a as u8);
- for index_b in 0..u8::BITS {
- let b = MyFlagsU8::from(index_b as u8);
- assert_eq!(MyFieldU8(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
- }
- }
- }
- bitwise_flag_xor_flag_u16 => {
- for index_a in 0..u16::BITS {
- let a = MyFlagsU16::from(index_a as u8);
- for index_b in 0..u16::BITS {
- let b = MyFlagsU16::from(index_b as u8);
- assert_eq!(MyFieldU16(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
- }
- }
- }
- bitwise_flag_xor_flag_u32 => {
- for index_a in 0..u32::BITS {
- let a = MyFlagsU32::from(index_a as u8);
- for index_b in 0..u32::BITS {
- let b = MyFlagsU32::from(index_b as u8);
- assert_eq!(MyFieldU32(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
- }
- }
- }
- bitwise_flag_xor_flag_u64 => {
- for index_a in 0..u64::BITS {
- let a = MyFlagsU64::from(index_a as u8);
- for index_b in 0..u64::BITS {
- let b = MyFlagsU64::from(index_b as u8);
- assert_eq!(MyFieldU64(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
- }
- }
- }
- bitwise_flag_xor_flag_u128 => {
- for index_a in 0..u128::BITS {
- let a = MyFlagsU128::from(index_a as u8);
- for index_b in 0..u128::BITS {
- let b = MyFlagsU128::from(index_b as u8);
- assert_eq!(MyFieldU128(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
- }
- }
- }
- // bitwise_flag_xor_flag_usize => {
- //
- // }
- }
-
- // flag from u8
- tests! {
- flag_from_u8_u8 => {
- for index in 0..u8::BITS {
- let _ = MyFlagsU8::from(index as u8);
- }
- }
- flag_from_u8_u16 => {
- for index in 0..u16::BITS {
- let _ = MyFlagsU16::from(index as u8);
- }
- }
- flag_from_u8_u32 => {
- for index in 0..u32::BITS {
- let _ = MyFlagsU32::from(index as u8);
- }
- }
- flag_from_u8_u64 => {
- for index in 0..u64::BITS {
- let _ = MyFlagsU64::from(index as u8);
- }
- }
- flag_from_u8_u128 => {
- for index in 0..u128::BITS {
- let _ = MyFlagsU128::from(index as u8);
- }
- }
- flag_from_u8_usize => {
- for index in 0..usize::BITS {
- let _ = MyFlagsUsize::from(index as u8);
- }
- }
- }
-
- // u8 from flag
- tests! {
- u8_from_flag_u8 => {
- for index in 0..u8::BITS {
- assert_eq!(MyFlagsU8::from(index as u8) as u8, index as u8)
- }
- }
- u8_from_flag_u16 => {
- for index in 0..u16::BITS {
- assert_eq!(MyFlagsU16::from(index as u8) as u8, index as u8)
- }
- }
- u8_from_flag_u32 => {
- for index in 0..u32::BITS {
- assert_eq!(MyFlagsU32::from(index as u8) as u8, index as u8)
- }
- }
- u8_from_flag_u64 => {
- for index in 0..u64::BITS {
- assert_eq!(MyFlagsU64::from(index as u8) as u8, index as u8)
- }
- }
- u8_from_flag_u128 => {
- for index in 0..u128::BITS {
- assert_eq!(MyFlagsU128::from(index as u8) as u8, index as u8)
- }
- }
- u8_from_flag_usize => {
- for index in 0..usize::BITS {
- assert_eq!(MyFlagsUsize::from(index as u8) as u8, index as u8)
- }
- }
- }
-}
-
-// -------------------------------------------------------------------------------------------------
-1//!
+2//! [](https://crates.io/crates/ubits)
+3//! [](https://crates.io/crates/ubits)
+4//! [](https://github.com/manoadamro/ubits/actions/workflows/rust.yml)
+5//! [](https://manoadamro.github.io/ubits/doc/ubits/)
+6//! [](https://github.com/manoadamro/ubits/blob/main/LICENSE)
+7//!
+8//! Bit fields and masks for rust!
+9//!
+10//! Provides a macro for generating [`bit field`](https://en.wikipedia.org/wiki/Bit_field) types
+11//! complete with flags and some helpful trait implementations.
+12//!
+13//! Supports field widths of `8`, `16`, `32`, `64` and `128` bits.
+14//!
+15//! - [`bitfield`] - macro documentation.
+16//! - [`examples`] - examples of the output generated by the [`bitfield`] macro.
+17//!
+18//! __Note: the example module is only complied with documentation builds
+19//! and is not available for importing in the wild.__
+20//!
+21//!
+22//! # Usage
+23//!
+24//! Generate a bitfield struct with a flag enum...
+25//! (The following examples all use this as a definition.)
+26//! ```rust
+27//! use ubits::bitfield;
+28//!
+29//! bitfield! {
+30//! pub u8 ExampleField
+31//! ExampleFlags {
+32//! 0 : Flag0,
+33//! 1 : Flag1,
+34//! 2 : Flag2,
+35//! 3 : Flag3,
+36//! 4 : Flag4,
+37//! 5 : Flag5,
+38//! 6 : Flag6,
+39//! 7 : Flag7,
+40//! }
+41//! }
+42//! ```
+43//!
+44//! ## Instances
+45//!
+46//! From integer:
+47//! ```rust
+48//! # use ubits::bitfield;
+49//! # bitfield! {
+50//! # pub u8 ExampleField
+51//! # ExampleFlags {
+52//! # 0 : Flag0,
+53//! # 1 : Flag1,
+54//! # 2 : Flag2,
+55//! # 3 : Flag3,
+56//! # 4 : Flag4,
+57//! # 5 : Flag5,
+58//! # 6 : Flag6,
+59//! # 7 : Flag7,
+60//! # }
+61//! # }
+62//!
+63//! let from_integer = ExampleField(123);
+64//! assert_eq!(ExampleField(123), from_integer);
+65//! ```
+66//!
+67//! From a binary string:
+68//! ```rust
+69//! # use ubits::bitfield;
+70//! # bitfield! {
+71//! # pub u8 ExampleField
+72//! # ExampleFlags {
+73//! # 0 : Flag0,
+74//! # 1 : Flag1,
+75//! # 2 : Flag2,
+76//! # 3 : Flag3,
+77//! # 4 : Flag4,
+78//! # 5 : Flag5,
+79//! # 6 : Flag6,
+80//! # 7 : Flag7,
+81//! # }
+82//! # }
+83//!
+84//! let from_binary = ExampleField::from_binary_str("01111011");
+85//! assert_eq!(ExampleField(123), from_binary)
+86//! ```
+87//!
+88//! From ones:
+89//! ```rust
+90//! # use ubits::bitfield;
+91//! # bitfield! {
+92//! # pub u8 ExampleField
+93//! # ExampleFlags {
+94//! # 0 : Flag0,
+95//! # 1 : Flag1,
+96//! # 2 : Flag2,
+97//! # 3 : Flag3,
+98//! # 4 : Flag4,
+99//! # 5 : Flag5,
+100//! # 6 : Flag6,
+101//! # 7 : Flag7,
+102//! # }
+103//! # }
+104//!
+105//! let from_ones = ExampleField::ones();
+106//! assert_eq!("11111111", from_ones.as_binary());
+107//! assert_eq!(255, from_ones.as_integer());
+108//! ```
+109//!
+110//! From zeros:
+111//! ```rust
+112//! # use ubits::bitfield;
+113//! # bitfield! {
+114//! # pub u8 ExampleField
+115//! # ExampleFlags {
+116//! # 0 : Flag0,
+117//! # 1 : Flag1,
+118//! # 2 : Flag2,
+119//! # 3 : Flag3,
+120//! # 4 : Flag4,
+121//! # 5 : Flag5,
+122//! # 6 : Flag6,
+123//! # 7 : Flag7,
+124//! # }
+125//! # }
+126//!
+127//! let from_zeros = ExampleField::zeros();
+128//! assert_eq!("00000000", from_zeros.as_binary());
+129//! assert_eq!(0, from_zeros.as_integer());
+130//! ```
+131//!
+132//! ### Field Access
+133//!
+134//! Get bit value by field:
+135//! ```rust
+136//! # use ubits::bitfield;
+137//! # bitfield! {
+138//! # pub u8 ExampleField
+139//! # ExampleFlags {
+140//! # 0 : Flag0,
+141//! # 1 : Flag1,
+142//! # 2 : Flag2,
+143//! # 3 : Flag3,
+144//! # 4 : Flag4,
+145//! # 5 : Flag5,
+146//! # 6 : Flag6,
+147//! # 7 : Flag7,
+148//! # }
+149//! # }
+150//!
+151//! let field = ExampleField::from_binary_str("01010101");
+152//! assert!(field.get(ExampleFlags::Flag0));
+153//! assert!(!field.get(ExampleFlags::Flag1));
+154//! ```
+155//!
+156//! Get bit value by index:
+157//!
+158//! ```rust
+159//! # use ubits::bitfield;
+160//! # bitfield! {
+161//! # pub u8 ExampleField
+162//! # ExampleFlags {
+163//! # 0 : Flag0,
+164//! # 1 : Flag1,
+165//! # 2 : Flag2,
+166//! # 3 : Flag3,
+167//! # 4 : Flag4,
+168//! # 5 : Flag5,
+169//! # 6 : Flag6,
+170//! # 7 : Flag7,
+171//! # }
+172//! # }
+173//!
+174//! let field = ExampleField::from_binary_str("01010101");
+175//! assert!(field.get_index(0));
+176//! assert!(!field.get_index(1));
+177//! ```
+178//!
+179//! Set bit value by field:
+180//!
+181//! ```rust
+182//! # use ubits::bitfield;
+183//! # bitfield! {
+184//! # pub u8 ExampleField
+185//! # ExampleFlags {
+186//! # 0 : Flag0,
+187//! # 1 : Flag1,
+188//! # 2 : Flag2,
+189//! # 3 : Flag3,
+190//! # 4 : Flag4,
+191//! # 5 : Flag5,
+192//! # 6 : Flag6,
+193//! # 7 : Flag7,
+194//! # }
+195//! # }
+196//!
+197//! let mut field = ExampleField::from_binary_str("01010101");
+198//! field.set(ExampleFlags::Flag1);
+199//! field.set(ExampleFlags::Flag3);
+200//! assert_eq!("01011111", field.as_binary());
+201//! ```
+202//!
+203//! Set bit value by index:
+204//!
+205//! ```rust
+206//! # use ubits::bitfield;
+207//! # bitfield! {
+208//! # pub u8 ExampleField
+209//! # ExampleFlags {
+210//! # 0 : Flag0,
+211//! # 1 : Flag1,
+212//! # 2 : Flag2,
+213//! # 3 : Flag3,
+214//! # 4 : Flag4,
+215//! # 5 : Flag5,
+216//! # 6 : Flag6,
+217//! # 7 : Flag7,
+218//! # }
+219//! # }
+220//!
+221//! let mut field = ExampleField::from_binary_str("01010101");
+222//! field.set_index(1);
+223//! field.set_index(3);
+224//! assert_eq!("01011111", field.as_binary());
+225//! ```
+226//!
+227//! Clear bit value by field:
+228//!
+229//! ```rust
+230//! # use ubits::bitfield;
+231//! # bitfield! {
+232//! # pub u8 ExampleField
+233//! # ExampleFlags {
+234//! # 0 : Flag0,
+235//! # 1 : Flag1,
+236//! # 2 : Flag2,
+237//! # 3 : Flag3,
+238//! # 4 : Flag4,
+239//! # 5 : Flag5,
+240//! # 6 : Flag6,
+241//! # 7 : Flag7,
+242//! # }
+243//! # }
+244//!
+245//! let mut field = ExampleField::from_binary_str("01010101");
+246//! field.clear(ExampleFlags::Flag0);
+247//! field.clear(ExampleFlags::Flag2);
+248//! assert_eq!("01010000", field.as_binary());
+249//! ```
+250//!
+251//! Clear bit value by index:
+252//!
+253//! ```rust
+254//! # use ubits::bitfield;
+255//! # bitfield! {
+256//! # pub u8 ExampleField
+257//! # ExampleFlags {
+258//! # 0 : Flag0,
+259//! # 1 : Flag1,
+260//! # 2 : Flag2,
+261//! # 3 : Flag3,
+262//! # 4 : Flag4,
+263//! # 5 : Flag5,
+264//! # 6 : Flag6,
+265//! # 7 : Flag7,
+266//! # }
+267//! # }
+268//!
+269//! let mut field = ExampleField::from_binary_str("01010101");
+270//! field.clear_index(0);
+271//! field.clear_index(2);
+272//! assert_eq!("01010000", field.as_binary());
+273//! ```
+274//!
+275//! Toggle bit value by field:
+276//!
+277//! ```rust
+278//! # use ubits::bitfield;
+279//! # bitfield! {
+280//! # pub u8 ExampleField
+281//! # ExampleFlags {
+282//! # 0 : Flag0,
+283//! # 1 : Flag1,
+284//! # 2 : Flag2,
+285//! # 3 : Flag3,
+286//! # 4 : Flag4,
+287//! # 5 : Flag5,
+288//! # 6 : Flag6,
+289//! # 7 : Flag7,
+290//! # }
+291//! # }
+292//!
+293//! let mut field = ExampleField::from_binary_str("01010101");
+294//! field.toggle(ExampleFlags::Flag0);
+295//! assert_eq!("01010100", field.as_binary());
+296//! field.toggle(ExampleFlags::Flag0);
+297//! assert_eq!("01010101", field.as_binary());
+298//! ```
+299//!
+300//! Toggle bit value by index:
+301//!
+302//! ```rust
+303//! # use ubits::bitfield;
+304//! # bitfield! {
+305//! # pub u8 ExampleField
+306//! # ExampleFlags {
+307//! # 0 : Flag0,
+308//! # 1 : Flag1,
+309//! # 2 : Flag2,
+310//! # 3 : Flag3,
+311//! # 4 : Flag4,
+312//! # 5 : Flag5,
+313//! # 6 : Flag6,
+314//! # 7 : Flag7,
+315//! # }
+316//! # }
+317//!
+318//! let mut field = ExampleField::from_binary_str("01010101");
+319//! field.toggle_index(0);
+320//! assert_eq!("01010100", field.as_binary());
+321//! field.toggle_index(0);
+322//! assert_eq!("01010101", field.as_binary());
+323//! ```
+324//!
+325//! ### Named Getters and Setters
+326//!
+327//! Ubits can generate getter and setter methods for zero or more fields, if a name is provided.
+328//!
+329//! ```rust
+330//! use ubits::bitfield;
+331//! bitfield! {
+332//! pub u8 ExampleField
+333//! ExampleFlags {
+334//! 0 : Flag0 : (field_0), // is_field_0 & set_field_0 & clear_field_0 & toggle_field_0
+335//! 1 : Flag1 : (field_1), // is_field_1 & set_field_1 & clear_field_1 & toggle_field_1
+336//! 2 : Flag2,
+337//! 3 : Flag3,
+338//! 4 : Flag4,
+339//! 5 : Flag5,
+340//! 6 : Flag6,
+341//! 7 : Flag7,
+342//! }
+343//! }
+344//!
+345//! let mut field = ExampleField::from_binary_str("01010101");
+346//! assert_eq!(true, field.is_field_0());
+347//! assert_eq!(false, field.is_field_1());
+348//!
+349//! field.set_field_1();
+350//! assert_eq!(true, field.is_field_1());
+351//!
+352//! field.clear_field_1();
+353//! assert_eq!(false, field.is_field_1());
+354//!
+355//! field.toggle_field_1();
+356//! assert_eq!(true, field.is_field_1());
+357//! ```
+358//!
+359//! ### Combinations
+360//!
+361//! Combine bit fields: <br>
+362//! (use `into_combined` to consume self)
+363//!
+364//! ```rust
+365//! # use ubits::bitfield;
+366//! # bitfield! {
+367//! # pub u8 ExampleField
+368//! # ExampleFlags {
+369//! # 0 : Flag0,
+370//! # 1 : Flag1,
+371//! # 2 : Flag2,
+372//! # 3 : Flag3,
+373//! # 4 : Flag4,
+374//! # 5 : Flag5,
+375//! # 6 : Flag6,
+376//! # 7 : Flag7,
+377//! # }
+378//! # }
+379//!
+380//! let mut a = ExampleField::from_binary_str("01010101");
+381//! let b = ExampleField::from_binary_str("10101010");
+382//! assert_eq!("11111111", a.combine(b).as_binary());
+383//! ```
+384//!
+385//! Get the intersection of two bitfields: <br>
+386//! (use `into_intersection` to consume self)
+387//! ```rust
+388//! # use ubits::bitfield;
+389//! # bitfield! {
+390//! # pub u8 ExampleField
+391//! # ExampleFlags {
+392//! # 0 : Flag0,
+393//! # 1 : Flag1,
+394//! # 2 : Flag2,
+395//! # 3 : Flag3,
+396//! # 4 : Flag4,
+397//! # 5 : Flag5,
+398//! # 6 : Flag6,
+399//! # 7 : Flag7,
+400//! # }
+401//! # }
+402//!
+403//! let mut a = ExampleField::from_binary_str("11000011");
+404//! let b = ExampleField::from_binary_str("01111110");
+405//! assert_eq!("01000010", a.intersect(b).as_binary());
+406//! ```
+407//!
+408//! Get the diff of two bitfields: <br>
+409//! (use `into_diff` to consume self)
+410//!
+411//! ```rust
+412//! # use ubits::bitfield;
+413//! # bitfield! {
+414//! # pub u8 ExampleField
+415//! # ExampleFlags {
+416//! # 0 : Flag0,
+417//! # 1 : Flag1,
+418//! # 2 : Flag2,
+419//! # 3 : Flag3,
+420//! # 4 : Flag4,
+421//! # 5 : Flag5,
+422//! # 6 : Flag6,
+423//! # 7 : Flag7,
+424//! # }
+425//! # }
+426//!
+427//! let mut a = ExampleField::from_binary_str("11000011");
+428//! let b = ExampleField::from_binary_str("01100110");
+429//! assert_eq!("10100101", a.diff(b).as_binary());
+430//! ```
+431//!
+432//! ### Bitwise
+433//!
+434//! Both bit field instances and flags use bitwise operators to change bit values.
+435//!
+436//! ```rust
+437//! # use ubits::bitfield;
+438//! # bitfield! {
+439//! # pub u8 ExampleField
+440//! # ExampleFlags {
+441//! # 0 : Flag0,
+442//! # 1 : Flag1,
+443//! # 2 : Flag2,
+444//! # 3 : Flag3,
+445//! # 4 : Flag4,
+446//! # 5 : Flag5,
+447//! # 6 : Flag6,
+448//! # 7 : Flag7,
+449//! # }
+450//! # }
+451//!
+452//! let mut from_zeros = ExampleField::zeros();
+453//! assert_eq!("00000000", from_zeros.as_binary());
+454//!
+455//! // set bit to 1
+456//! from_zeros |= ExampleFlags::Flag1;
+457//! assert_eq!("00000010", from_zeros.as_binary());
+458//!
+459//! // set bit back to 0
+460//! from_zeros &= ExampleFlags::Flag1;
+461//! assert_eq!("00000000", from_zeros.as_binary());
+462//!
+463//! // toggle a bit
+464//! from_zeros ^= ExampleFlags::Flag1;
+465//! assert_eq!("00000010", from_zeros.as_binary());
+466//!
+467//! from_zeros ^= ExampleFlags::Flag1;
+468//! assert_eq!("00000000", from_zeros.as_binary());
+469//! ```
+470//!
+471//! Operations can also be chained together:
+472//!
+473//! ```rust
+474//! # use ubits::bitfield;
+475//! # bitfield! {
+476//! # pub u8 ExampleField
+477//! # ExampleFlags {
+478//! # 0 : Flag0,
+479//! # 1 : Flag1,
+480//! # 2 : Flag2,
+481//! # 3 : Flag3,
+482//! # 4 : Flag4,
+483//! # 5 : Flag5,
+484//! # 6 : Flag6,
+485//! # 7 : Flag7,
+486//! # }
+487//! # }
+488//!
+489//! let mut from_zeros = ExampleField::zeros() | ExampleFlags::Flag1 | ExampleFlags::Flag3;
+490//! assert_eq!("00001010", from_zeros.as_binary());
+491//!
+492//! ```
+493//!
+494//! Bitfield instances can also be created from combining flags:
+495//!
+496//! ```rust
+497//! # use ubits::bitfield;
+498//! # bitfield! {
+499//! # pub u8 ExampleField
+500//! # ExampleFlags {
+501//! # 0 : Flag0,
+502//! # 1 : Flag1,
+503//! # 2 : Flag2,
+504//! # 3 : Flag3,
+505//! # 4 : Flag4,
+506//! # 5 : Flag5,
+507//! # 6 : Flag6,
+508//! # 7 : Flag7,
+509//! # }
+510//! # }
+511//!
+512//! let mut from_zeros = ExampleFlags::Flag1 | ExampleFlags::Flag3;
+513//! assert_eq!("00001010", from_zeros.as_binary());
+514//!
+515//! ```
+516//!
+517//! ## Fields named with flags
+518//!
+519//! The generated flags enum allows you to access bits by name.
+520//! The flag has an associated [`u8`] value,
+521//! which determines the index its target bit.
+522//! (See [`bitfield`] for more info)
+523//!
+524//! With the following input...
+525//! ```no_compile
+526//! 1 0 1 0 0 1 1 0
+527//! ```
+528//!
+529//! and the following flags...
+530//! ```no_compile
+531//! 0 : f1
+532//! 1 : f1
+533//! 2 : f2
+534//! 3 : f3
+535//! 4 : f4
+536//! 5 : f5
+537//! 6 : f6
+538//! 7 : f7
+539//! ```
+540//!
+541//! we end up with this layout.
+542//!
+543//! | name | f7 | f6 | f5 | f4 | f3 | f2 | f1 | f0 |
+544//! |-----------|----|----|----|----|----|----|----|----|
+545//! | bit value | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
+546//! | index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+547//!
+548//!
+549//! With the same input and only the first few flags:
+550//!
+551//! ```no_compile
+552//! 0 : f0
+553//! 1 : f1
+554//! 2 : f2
+555//! ```
+556//!
+557//! we end up with this layout.
+558//!
+559//! | name | | | | | | f2 | f1 | f0 |
+560//! |-----------|----|----|----|----|----|----|----|----|
+561//! | bit value | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
+562//! | index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+563//!
+564//!
+565//! Using the same input, but with dispersed flags:
+566//!
+567//! ```no_compile
+568//! 1 : f0
+569//! 3 : f1
+570//! 6 : f2
+571//! ```
+572//!
+573//! we end up with this layout.
+574//!
+575//! | name | | f2 | | | f1 | | f0 | |
+576//! |-----------|----|----|----|----|----|----|----|----|
+577//! | bit value | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 |
+578//! | index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+579//!
+580
+581// -------------------------------------------------------------------------------------------------
+582// Imports
+583
+584extern crate doc_comment;
+585extern crate paste;
+586extern crate safe_transmute;
+587
+588#[doc(hidden)]
+589pub use doc_comment::doc_comment as __doc_comment;
+590
+591#[doc(hidden)]
+592pub use safe_transmute::{
+593 transmute_one as __transmute_one, TriviallyTransmutable as __TriviallyTransmutable,
+594};
+595
+596#[doc(hidden)]
+597pub use paste::paste as __paste;
+598
+599// -------------------------------------------------------------------------------------------------
+600// Generator Macros
+601
+602/// Generates a bitfield struct and a corresponding flag enum.
+603///
+604/// Can be used multiple times in a single codebase
+605/// as long as the identifiers are unique or are isolated so as not to clash.
+606///
+607/// __See the [`examples`] module for examples of the generated output.__
+608///
+609/// # Args
+610///
+611/// - `pub` - optional accessor: if provided, both generated items will public.
+612/// If omitted, both will be private. <br>
+613/// [see here](https://doc.rust-lang.org/reference/visibility-and-privacy.html#visibility-and-privacy) for possible visibility options.
+614///
+615/// - `ExampleField` - name for the generated bitfield struct.
+616/// (results in `struct ExampleField(...)`)
+617///
+618/// - `ExampleFlags` - name for the generated flag enum.
+619/// (results in `enum ExampleFlags { ... }`)
+620///
+621/// - `u8` - unsigned integer type to use as a bit array. *Must be an unsigned integer* <br>
+622/// valid options are: [`u8`],[`u16`], [`u32`], [`u64`], [`u128`], [`usize`]
+623///
+624/// - `0 : Flag0` - defines each member of the flag enum. <br>
+625/// The left hand side must be a [`u8`] `(0..=254)`
+626/// and must be less than the number of bits in the underlying unsigned type.
+627/// This value determines the index of the target bit within the field. <br>
+628/// The right hand side can be any valid identifier (unique to this enum).
+629/// These identifiers will be used to access the corresponding field.
+630///
+631/// - `/// docstrings` - Each element can take optional docstrings.
+632/// This includes the bit field struct, the flag enum, and each member within the flag enum.
+633/// See [`examples`] for more information.
+634///
+635/// # Examples:
+636///
+637/// Full Example - (see below for explanation for each parameter):
+638/// ```rust
+639/// use ubits::bitfield;
+640///
+641/// bitfield! {
+642/// /// Optional docstring
+643/// /// for [`ExampleField`] struct
+644/// pub u8 ExampleField
+645/// /// Optional docstring
+646/// /// for [`ExampleFlags`] enum
+647/// ExampleFlags {
+648/// /// Optional docstring for [`ExampleFlags::Flag0`]
+649/// 0 : Flag0,
+650/// /// Optional docstring for [`ExampleFlags::Flag1`]
+651/// 1 : Flag1,
+652/// /// Optional docstring for [`ExampleFlags::Flag2`]
+653/// 2 : Flag2,
+654/// /// Optional docstring for [`ExampleFlags::Flag3`]
+655/// 3 : Flag3,
+656/// /// Optional docstring for [`ExampleFlags::Flag4`]
+657/// 4 : Flag4,
+658/// /// Optional docstring for [`ExampleFlags::Flag5`]
+659/// 5 : Flag5,
+660/// /// Optional docstring for [`ExampleFlags::Flag6`]
+661/// 6 : Flag6,
+662/// /// Optional docstring for [`ExampleFlags::Flag7`]
+663/// 7 : Flag7,
+664/// }
+665/// }
+666/// ```
+667///
+668/// You don't have to name *all* the fields if you don't need them...
+669///
+670/// You can use just a few from the front:
+671/// ```rust
+672/// use ubits::bitfield;
+673///
+674/// bitfield! {
+675/// /// Optional docstring
+676/// /// for [`ExampleField`] struct
+677/// pub u8 ExampleField
+678/// /// Optional docstring
+679/// /// for [`ExampleFlags`] enum
+680/// ExampleFlags {
+681/// /// Optional docstring for [`ExampleFlags::Flag0`]
+682/// 0 : Flag0,
+683/// /// Optional docstring for [`ExampleFlags::Flag1`]
+684/// 1 : Flag1,
+685/// /// Optional docstring for [`ExampleFlags::Flag2`]
+686/// 2 : Flag2,
+687/// }
+688/// }
+689/// ```
+690///
+691/// ... or any valid indices:
+692/// ```rust
+693/// use ubits::bitfield;
+694///
+695/// bitfield! {
+696/// /// Optional docstring
+697/// /// for [`ExampleField`] struct
+698/// pub u8 ExampleField
+699/// /// Optional docstring
+700/// /// for [`ExampleFlags`] enum
+701/// ExampleFlags {
+702/// /// Optional docstring for [`ExampleFlags::Flag0`]
+703/// 0 : Flag0,
+704/// /// Optional docstring for [`ExampleFlags::Flag1`]
+705/// 3 : Flag1,
+706/// /// Optional docstring for [`ExampleFlags::Flag2`]
+707/// 6 : Flag2,
+708/// }
+709/// }
+710/// ```
+711/// ... or just omit the flags altogether and use indices only.:
+712/// ```rust
+713/// use ubits::bitfield;
+714/// bitfield! {
+715/// /// Optional docstring
+716/// /// for [`ExampleField`] struct
+717/// pub u8 ExampleField
+718/// }
+719/// ```
+720/// __Note: if you omit flags, no flag enum will be generated
+721/// and no methods for the bitfield struct that rely on flags will be generated.__
+722///
+723#[macro_export(local_inner_macros)]
+724macro_rules! bitfield {
+725
+726 // U8
+727 (
+728 $(#[$doc:meta])*
+729 $access:vis u8 $name:ident
+730 $(
+731 $(#[$flag_doc:meta])*
+732 $flag:ident {
+733 $(
+734 $(#[$member_doc:meta])*
+735 $idx:literal : $field:ident $( : ( $named_getter:ident ) )?,
+736 )*
+737 }
+738 )?
+739 ) => {
+740 __bitfield_unchecked!( $(#[$doc])* $access [u8] [8] [u8::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
+741 };
+742
+743 // U16
+744 (
+745 $(#[$doc:meta])*
+746 $access:vis u16 $name:ident
+747 $(
+748 $(#[$flag_doc:meta])*
+749 $flag:ident {
+750 $(
+751 $(#[$member_doc:meta])*
+752 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+753 )*
+754 }
+755 )?
+756 ) => {
+757 __bitfield_unchecked!( $(#[$doc])* $access [u16] [16] [u16::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
+758 };
+759
+760 // U32
+761 (
+762 $(#[$doc:meta])*
+763 $access:vis u32 $name:ident
+764 $(
+765 $(#[$flag_doc:meta])*
+766 $flag:ident {
+767 $(
+768 $(#[$member_doc:meta])*
+769 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+770 )*
+771 }
+772 )?
+773 ) => {
+774 __bitfield_unchecked!( $(#[$doc])* $access [u32] [32] [u32::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
+775 };
+776
+777 // U64
+778 (
+779 $(#[$doc:meta])*
+780 $access:vis u64 $name:ident
+781 $(
+782 $(#[$flag_doc:meta])*
+783 $flag:ident {
+784 $(
+785 $(#[$member_doc:meta])*
+786 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+787 )*
+788 }
+789 )?
+790 ) => {
+791 __bitfield_unchecked!( $(#[$doc])* $access [u64] [64] [u64::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
+792 };
+793
+794 // U128
+795 (
+796 $(#[$doc:meta])*
+797 $access:vis u128 $name:ident
+798 $(
+799 $(#[$flag_doc:meta])*
+800 $flag:ident {
+801 $(
+802 $(#[$member_doc:meta])*
+803 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+804 )*
+805 }
+806 )?
+807 ) => {
+808 __bitfield_unchecked!( $(#[$doc])* $access [u128] [128] [u128::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
+809 };
+810
+811 // USIZE
+812 (
+813 $(#[$doc:meta])*
+814 $access:vis usize $name:ident
+815 $(
+816 $(#[$flag_doc:meta])*
+817 $flag:ident {
+818 $(
+819 $(#[$member_doc:meta])*
+820 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+821 )*
+822 }
+823 )?
+824 ) => {
+825 __bitfield_unchecked!( $(#[$doc])* $access [usize] [usize::BITS as usize] [usize::MAX] $name $($(#[$flag_doc])* $flag { $( $(#[$member_doc])* $idx : $field $(($named_getter))?, )* } )?);
+826 };
+827}
+828
+829/// Not to be used directly.
+830///
+831/// Generates a bitfield struct and flag enum
+832/// but does no type checking.
+833/// Passing types that aren't unsigned integer types is undefined behaviour.
+834///
+835/// Use the [`bitfield`] macro instead as it enforces a closed set of types.
+836#[doc(hidden)]
+837#[macro_export(local_inner_macros)]
+838macro_rules! __bitfield_unchecked {
+839 (
+840 $(#[$field_doc:meta])*
+841 $access:vis [$type:ty] [$($bits:tt)*] [$max:path] $name:ident
+842 $(
+843 $(#[$flag_doc:meta])*
+844 $flag:ident {
+845 $(
+846 $(#[$member_doc:meta])*
+847 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+848 )*
+849 }
+850 )?
+851 ) => {
+852
+853 $(
+854 __def_flag_enum! {
+855 $(#[$flag_doc])*
+856 $access $name
+857 $flag {
+858 $(
+859 $(#[$member_doc])*
+860 $idx : $field $(($named_getter))?,
+861 )*
+862 }
+863 }
+864 )?
+865
+866 __def_field_struct! {
+867 $(#[$field_doc])*
+868 $access [$type] [$($bits)*] [$max] $name
+869 $(
+870 $flag {
+871 $(
+872 $(#[$member_doc])*
+873 $idx : $field $(($named_getter))?,
+874 )*
+875 }
+876 )?
+877 }
+878 };
+879}
+880
+881// -------------------------------------------------------------------------------------------------
+882// Type Definitions
+883
+884/// Defines a field struct with its members and implementations
+885#[doc(hidden)]
+886#[macro_export(local_inner_macros)]
+887macro_rules! __def_field_struct {
+888 (
+889 $(#[$field_doc:meta])*
+890 $access:vis [$type:ty] [$($bits:tt)*] [$max:path] $name:ident
+891 $(
+892 $flag:ident {
+893 $(
+894 $(#[$member_doc:meta])*
+895 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+896 )*
+897 }
+898 )?
+899 ) => {
+900
+901 // Struct: $name
+902 $(#[$field_doc])*
+903 #[derive(Copy, Clone, PartialEq, PartialOrd)]
+904 $access struct $name($type);
+905
+906 $(
+907 impl $name {
+908 $(
+909 $(
+910 __paste! {
+911 pub fn [< is_ $named_getter >](&self) -> bool {
+912 self.get($flag::$field)
+913 }
+914 }
+915
+916 __paste! {
+917 pub fn [< set_ $named_getter >](&mut self) {
+918 self.set($flag::$field);
+919 }
+920 }
+921
+922 __paste! {
+923 pub fn [< clear_ $named_getter >](&mut self) {
+924 self.clear($flag::$field);
+925 }
+926 }
+927
+928 __paste! {
+929 pub fn [< toggle_ $named_getter >](&mut self) {
+930 self.toggle($flag::$field);
+931 }
+932 }
+933 )?
+934 )*
+935 }
+936 )?
+937
+938 // Constants
+939 __impl_field_constants! {
+940 $name { type: $type, max: $max, bits: [$($bits)*] }
+941 }
+942
+943 // Constructors
+944 __impl_field_ctors! {
+945 $name : $type
+946 }
+947
+948 // State
+949 __impl_field_state! {
+950 $name : $type
+951 }
+952
+953 // Indexers
+954 __impl_field_index_accessors! {
+955 $name
+956 }
+957
+958 $(
+959 // Flags
+960 __impl_field_flag_accessors! {
+961 $name $flag $type
+962 }
+963 )?
+964
+965 // Combinators
+966 __impl_field_flag_combinators! {
+967 $name
+968 }
+969
+970 // Converters
+971 __impl_field_flag_converters! {
+972 $name
+973 }
+974
+975 // Name: $name
+976 __impl_default! {
+977 $name => { $name(0) }
+978 }
+979
+980 // From: $type -> $name
+981 __impl_from! {
+982 /// Returns a field instance from value of its underlying type.
+983 $type as $name (value) => {
+984 $name(value)
+985 }
+986 }
+987
+988 $(
+989 // From: $flag -> $name
+990 __impl_from! {
+991 /// Returns a field instance from a flag.
+992 $flag as $name (value) => {
+993 Self(0 | (1 << (value as $type)) )
+994 }
+995 }
+996 )?
+997
+998 // Bitwise: $name + $name
+999 __impl_bitwise_operators! {
+1000 [Self] for $name : (self rhs -> Self)
+1001 BitAnd => { Self(self.0 & rhs.0) }
+1002 BitOr => { Self(self.0 | rhs.0) }
+1003 BitXor => { Self(self.0 ^ rhs.0) }
+1004 BitAndAssign => { self.0 &= rhs.0; }
+1005 BitOrAssign => { self.0 |= rhs.0; }
+1006 BitXorAssign => { self.0 ^= rhs.0; }
+1007 }
+1008
+1009 $(
+1010 // Bitwise: $name + $flag
+1011 __impl_bitwise_operators! {
+1012 [$flag] for $name : (self rhs -> $name)
+1013 BitAnd => { $name(self.0 & !(1 << (rhs as $type))) }
+1014 BitOr => { $name(self.0 | (1 << (rhs as $type))) }
+1015 BitXor => { $name(self.0 ^ (1 << (rhs as $type))) }
+1016 BitAndAssign => { self.clear(rhs); }
+1017 BitOrAssign => { self.set(rhs); }
+1018 BitXorAssign => { self.toggle(rhs); }
+1019 }
+1020
+1021 // Bitwise: &$name + $flag
+1022 __impl_bitwise_operators! {
+1023 [$flag] for & $name : (self rhs -> $name)
+1024 BitAnd => { $name(self.0 & !(1 << (rhs as $type))) }
+1025 BitOr => { $name(self.0 | (1 << (rhs as $type))) }
+1026 BitXor => { $name(self.0 ^ (1 << (rhs as $type))) }
+1027 }
+1028
+1029 // Bitwise: $mut $name + $flag
+1030 __impl_bitwise_operators! {
+1031 [$flag] for &mut $name : (self rhs -> $name)
+1032 BitAnd => { $name(self.0 & !(1 << (rhs as $type))) }
+1033 BitOr => { $name(self.0 | (1 << (rhs as $type))) }
+1034 BitXor => { $name(self.0 ^ (1 << (rhs as $type))) }
+1035 }
+1036 )?
+1037
+1038 // Bitwise: Debug & Binary
+1039 __impl_formatters! {
+1040 $name (self f) {
+1041 Debug => { core::write!(f, "{}({})", core::stringify!($name), self.as_binary()) }
+1042 Binary => { core::write!(f, "{}", self.as_binary()) }
+1043 }
+1044 }
+1045 };
+1046}
+1047
+1048/// Defines a flag enum with its members and implementations
+1049#[doc(hidden)]
+1050#[macro_export(local_inner_macros)]
+1051macro_rules! __def_flag_enum {
+1052 (
+1053 $(#[$flag_doc:meta])*
+1054 $access:vis $name:ident
+1055 $flag:ident {
+1056 $(
+1057 $(#[$member_doc:meta])*
+1058 $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+1059 )*
+1060 }
+1061 ) => {
+1062
+1063 // Enum: $flag
+1064 $(#[$flag_doc])*
+1065 #[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
+1066 #[repr(u8)]
+1067 $access enum $flag {
+1068 $( $(#[$member_doc])* $field = $idx ),*
+1069 }
+1070
+1071 // Bitwise: $flag + $flag
+1072 __impl_bitwise_operators! {
+1073 [Self] for $flag : (self rhs -> $name)
+1074 BitAnd => { $name(0).clear(self) & rhs }
+1075 BitOr => { $name(0).set(self) | rhs }
+1076 BitXor => { $name(0).toggle(self) ^ rhs }
+1077 }
+1078
+1079 // Bitwise: u8 -> $flag
+1080 __impl_from! {
+1081 /// Converts a [`u8`] to a flag
+1082 ///
+1083 /// # Errors
+1084 ///
+1085 /// Panics if the supplied [`u8`] is out of range for fields base type.
+1086 /// eg: for a 16-bit field (using [`u16`]),
+1087 /// providing an index of `20` will cause a panic.
+1088 u8 as $flag (value) => {
+1089 $crate::__transmute_one::<$flag>(&[value])
+1090 .expect(std::format!(
+1091 "failed to transmute {} to {}. {} is not a valid index in {}.",
+1092 value,
+1093 core::stringify!($flag),
+1094 value,
+1095 core::stringify!($flag)
+1096 ).as_str())
+1097 }
+1098 }
+1099
+1100 // Bitwise: $flag -> u8
+1101 __impl_from! {
+1102 /// Returns a flag as its corresponding [`u8`] value.
+1103 $flag as u8 (value) => {
+1104 value as u8
+1105 }
+1106 }
+1107
+1108 unsafe impl $crate::__TriviallyTransmutable for $flag {}
+1109 };
+1110}
+1111
+1112// -------------------------------------------------------------------------------------------------
+1113// Field Implementations
+1114
+1115/// Generates constants for `$name`
+1116#[doc(hidden)]
+1117#[macro_export]
+1118macro_rules! __impl_field_constants {
+1119 ($name:ident { type: $type:ty, max: $max:path, bits: [$($bits:tt)*] }) => {
+1120 $crate::__doc_comment! {
+1121 core::concat!(
+1122 "Constant values describing [`", core::stringify!($name), "`]."
+1123 ),
+1124 impl $name {
+1125 $crate::__doc_comment! {
+1126 core::concat!(
+1127 "Number of bits in an instance of [`", core::stringify!($name), "`]."
+1128 ),
+1129 pub const BITS: usize = $($bits)*;
+1130 }
+1131 $crate::__doc_comment! {
+1132 core::concat!(
+1133 "Number of bytes used by an instance of [`", core::stringify!($name), "`]."
+1134 ),
+1135 pub const BYTES: usize = $($bits)* / 8;
+1136 }
+1137 $crate::__doc_comment! {
+1138 core::concat!(
+1139 "Maximum valid integer for [`", core::stringify!($name), "`]."
+1140 ),
+1141 pub const MAX: $type = $max;
+1142 }
+1143 }
+1144 }
+1145 };
+1146}
+1147
+1148/// Generates constructors for `$name`
+1149#[doc(hidden)]
+1150#[macro_export]
+1151macro_rules! __impl_field_ctors {
+1152 ( $name:ident : $type:ty ) => {
+1153 $crate::__doc_comment! {
+1154 core::concat!(
+1155 "Constructors for creating instances of [`", core::stringify!($name), "`]."
+1156 ),
+1157 impl $name {
+1158 $crate::__doc_comment! {
+1159 core::concat!(
+1160 "Create a new instance of [`", core::stringify!($name), "`] ",
+1161 "from a [`", core::stringify!($type), "`] value."
+1162 ),
+1163 pub fn new(value: $type) -> Self {
+1164 Self(value)
+1165 }
+1166 }
+1167
+1168 $crate::__doc_comment! {
+1169 core::concat!(
+1170 "Create a new instance of [`", core::stringify!($name), "`] ",
+1171 "from `0`."
+1172 ),
+1173 pub fn zeros() -> Self {
+1174 Self(0)
+1175 }
+1176 }
+1177
+1178 $crate::__doc_comment! {
+1179 core::concat!(
+1180 "Create a new instance of [`", core::stringify!($name), "`] ",
+1181 "from the maximum possible integer value."
+1182 ),
+1183 pub fn ones() -> Self {
+1184 Self(Self::MAX)
+1185 }
+1186 }
+1187
+1188 $crate::__doc_comment! {
+1189 core::concat!(
+1190 "Create a new instance of [`", core::stringify!($name), "`] ",
+1191 "from a binary string."
+1192 ),
+1193 pub fn from_binary_str(value: &str) -> Self {
+1194 Self(<$type>::from_str_radix(value, 2).unwrap())
+1195 }
+1196 }
+1197
+1198 $crate::__doc_comment! {
+1199 core::concat!(
+1200 "Create a new instance of [`", core::stringify!($name), "`] ",
+1201 "from a binary string."
+1202 ),
+1203 pub fn from_binary_string(value: String) -> Self {
+1204 Self(<$type>::from_str_radix(value.as_str(), 2).unwrap())
+1205 }
+1206 }
+1207 }
+1208 }
+1209 };
+1210}
+1211
+1212/// Generates getters for state fields in `$name`
+1213#[doc(hidden)]
+1214#[macro_export]
+1215macro_rules! __impl_field_state {
+1216 ($name:ident : $type:ty) => {
+1217 $crate::__doc_comment! {
+1218 core::concat!(
+1219 "Current state of this bitfield."
+1220 ),
+1221 impl $name {
+1222 $crate::__doc_comment! {
+1223 core::concat!(
+1224 "Returns the current field value as a [`", core::stringify!($type), "`]"
+1225 ),
+1226 pub fn as_integer(&self) -> $type {
+1227 self.0
+1228 }
+1229 }
+1230
+1231 $crate::__doc_comment! {
+1232 core::concat!(
+1233 "Returns the current field value as a binary formatted string."
+1234 ),
+1235 pub fn as_binary(&self) -> String {
+1236 std::format!("{:0width$b}", self.0, width = Self::BITS)
+1237 }
+1238 }
+1239 }
+1240 }
+1241 };
+1242}
+1243
+1244/// Generates getters by index for bit fields in `$name`
+1245#[doc(hidden)]
+1246#[macro_export]
+1247macro_rules! __impl_field_index_accessors {
+1248 ($name:ident) => {
+1249 $crate::__doc_comment! {
+1250 core::concat!(
+1251 "Field accessors by index for [`", core::stringify!($name), "`]."
+1252 ),
+1253 impl $name {
+1254 $crate::__doc_comment! {
+1255 core::concat!(
+1256 "Returns the value of the bit at the supplied index as a boolean."
+1257 ),
+1258 pub fn get_index(&self, index: u8) -> bool {
+1259 ((self.0 >> index) & 1) == 1
+1260 }
+1261 }
+1262
+1263 $crate::__doc_comment! {
+1264 core::concat!(
+1265 "Sets the value of the bit at the supplied index to `1`."
+1266 ),
+1267 pub fn set_index(&mut self, index: u8) {
+1268 self.0 |= (1 << index);
+1269 }
+1270 }
+1271
+1272 $crate::__doc_comment! {
+1273 core::concat!(
+1274 "Sets the value of the bit at the supplied index to `0`."
+1275 ),
+1276 pub fn clear_index(&mut self, index: u8) {
+1277 self.0 &= !(1 << index);
+1278 }
+1279 }
+1280
+1281 $crate::__doc_comment! {
+1282 core::concat!(
+1283 "Flips the value of the bit at the supplied index."
+1284 ),
+1285 pub fn toggle_index(&mut self, index: u8) {
+1286 self.0 ^= (1 << index);
+1287 }
+1288 }
+1289 }
+1290 }
+1291 };
+1292}
+1293
+1294/// Generates getters by flag for bit fields in `$name`
+1295#[doc(hidden)]
+1296#[macro_export]
+1297macro_rules! __impl_field_flag_accessors {
+1298 ($name:ident $flag:ident $type:ty) => {
+1299 $crate::__doc_comment! {
+1300 core::concat!(
+1301 "Named field accessors by [`", core::stringify!($flag), "`] for [`", core::stringify!($name), "`]."
+1302 ),
+1303 impl $name {
+1304 $crate::__doc_comment! {
+1305 core::concat!(
+1306 "Returns the value of the bit at the supplied flag as a boolean."
+1307 ),
+1308 pub fn get(&self, flag: $flag) -> bool {
+1309 ((self.0 >> (flag as $type)) & 1) == 1
+1310 }
+1311 }
+1312
+1313 $crate::__doc_comment! {
+1314 core::concat!(
+1315 "Sets the value of the bit at the supplied flag to `1`."
+1316 ),
+1317 pub fn set(&mut self, flag: $flag) -> &mut Self {
+1318 self.0 |= (1 << (flag as $type));
+1319 self
+1320 }
+1321 }
+1322
+1323 $crate::__doc_comment! {
+1324 core::concat!(
+1325 "Sets the value of the bit at the supplied flag to `0`."
+1326 ),
+1327 pub fn clear(&mut self, flag: $flag) -> &mut Self {
+1328 self.0 &= !(1 << (flag as $type));
+1329 self
+1330 }
+1331 }
+1332
+1333 $crate::__doc_comment! {
+1334 core::concat!(
+1335 "Flips the value of the bit at the supplied flag."
+1336 ),
+1337 pub fn toggle(&mut self, flag: $flag) -> &mut Self {
+1338 self.0 ^= (1 << (flag as $type));
+1339 self
+1340 }
+1341 }
+1342 }
+1343 }
+1344 };
+1345}
+1346
+1347/// Generates combinator methods for `$name`
+1348#[doc(hidden)]
+1349#[macro_export]
+1350macro_rules! __impl_field_flag_combinators {
+1351 ($name:ident) => {
+1352 $crate::__doc_comment! {
+1353 core::concat!(
+1354 "Combinators for [`", core::stringify!($name), "`]."
+1355 ),
+1356 impl $name {
+1357 $crate::__doc_comment! {
+1358 core::concat!(
+1359 "Returns a new [`", core::stringify!($name), "`]",
+1360 "with ones for flags that do not match. ",
+1361 "Does not consume `self`."
+1362 ),
+1363 pub fn diff(&self, other: Self) -> Self {
+1364 Self(self.0 ^ other.0)
+1365 }
+1366 }
+1367
+1368 $crate::__doc_comment! {
+1369 core::concat!(
+1370 "Returns a new [`", core::stringify!($name), "`]",
+1371 "with ones for flags that were set on either input. ",
+1372 "Does not consume `self`."
+1373 ),
+1374 pub fn combine(&self, other: Self) -> Self {
+1375 Self(self.0 | other.0)
+1376 }
+1377 }
+1378
+1379 $crate::__doc_comment! {
+1380 core::concat!(
+1381 "Returns a new [`", core::stringify!($name), "`]",
+1382 "with ones for flags that were set on both inputs. ",
+1383 "Does not consume `self`."
+1384 ),
+1385 pub fn intersect(&self, other: Self) -> Self {
+1386 Self(self.0 & other.0)
+1387 }
+1388 }
+1389 }
+1390 }
+1391 };
+1392}
+1393
+1394/// Generates conversion methods for `$name`
+1395#[doc(hidden)]
+1396#[macro_export]
+1397macro_rules! __impl_field_flag_converters {
+1398 ($name:ident) => {
+1399 $crate::__doc_comment! {
+1400 core::concat!(
+1401 "Conversion methods."
+1402 ),
+1403 impl $name {
+1404 $crate::__doc_comment! {
+1405 core::concat!(
+1406 "Returns a new [`", core::stringify!($name), "`]",
+1407 "with ones for flags that do not match. ",
+1408 "Consumes `self`."
+1409 ),
+1410 pub fn into_diff(self, other: Self) -> Self {
+1411 Self(self.0 ^ other.0)
+1412 }
+1413 }
+1414
+1415 $crate::__doc_comment! {
+1416 core::concat!(
+1417 "Returns a new [`", core::stringify!($name), "`]",
+1418 "with ones for flags that were set on either input. ",
+1419 "Consumes `self`."
+1420 ),
+1421 pub fn into_combined(self, other: Self) -> Self {
+1422 Self(self.0 | other.0)
+1423 }
+1424 }
+1425
+1426 $crate::__doc_comment! {
+1427 core::concat!(
+1428 "Returns a new [`", core::stringify!($name), "`]",
+1429 "with ones for flags that were set on both inputs. ",
+1430 "Consumes `self`."
+1431 ),
+1432 pub fn into_intersection(self, other: Self) -> Self {
+1433 Self(self.0 & other.0)
+1434 }
+1435 }
+1436 }
+1437 }
+1438 };
+1439}
+1440
+1441// -------------------------------------------------------------------------------------------------
+1442// Trait Implementations
+1443
+1444// Operators
+1445
+1446/// Generates a set of bitwise operators
+1447/// for a set of parameters
+1448#[doc(hidden)]
+1449#[macro_export(local_inner_macros)]
+1450macro_rules! __impl_bitwise_operators {
+1451
+1452 // Owned
+1453 (
+1454 [$flag:ty] for $dest:ident : ($self:ident $other:ident -> $output:ident)
+1455 $( BitAnd => $bitand:block )?
+1456 $( BitOr => $bitor:block )?
+1457 $( BitXor => $bitxor:block )?
+1458 $( BitAndAssign => $bitand_assign:block )?
+1459 $( BitOrAssign => $bitor_assign:block )?
+1460 $( BitXorAssign => $bitxor_assign:block )?
+1461 ) => {
+1462 $( __impl_operator! {BitAnd [$flag] bitand for $dest ($self $other -> $output) => $bitand} )?
+1463 $( __impl_operator! {BitOr [$flag] bitor for $dest ($self $other -> $output) => $bitor} )?
+1464 $( __impl_operator! {BitXor [$flag] bitxor for $dest ($self $other -> $output) => $bitxor} )?
+1465
+1466 $( __impl_assign_operator! {BitAndAssign [$flag] bitand_assign for $dest ($self $other) => $bitand_assign} )?
+1467 $( __impl_assign_operator! {BitOrAssign [$flag] bitor_assign for $dest ($self $other) => $bitor_assign} )?
+1468 $( __impl_assign_operator! {BitXorAssign [$flag] bitxor_assign for $dest ($self $other) => $bitxor_assign} )?
+1469 };
+1470
+1471 // Reference
+1472 (
+1473 [$flag:ty] for & $dest:ident : ($self:ident $other:ident -> $output:ident)
+1474 $( BitAnd => $bitand:block )?
+1475 $( BitOr => $bitor:block )?
+1476 $( BitXor => $bitxor:block )?
+1477 ) => {
+1478 $( __impl_operator! {BitAnd [$flag] bitand for & $dest ($self $other -> $output) => $bitand} )?
+1479 $( __impl_operator! {BitOr [$flag] bitor for & $dest ($self $other -> $output) => $bitor} )?
+1480 $( __impl_operator! {BitXor [$flag] bitxor for & $dest ($self $other -> $output) => $bitxor} )?
+1481 };
+1482
+1483 // Mutable Reference
+1484 (
+1485 [$flag:ty] for &mut $dest:ident : ($self:ident $other:ident -> $output:ident)
+1486 $( BitAnd => $bitand:block )?
+1487 $( BitOr => $bitor:block )?
+1488 $( BitXor => $bitxor:block )?
+1489 ) => {
+1490 $( __impl_operator! {BitAnd [$flag] bitand for &mut $dest ($self $other -> $output) => $bitand} )?
+1491 $( __impl_operator! {BitOr [$flag] bitor for &mut $dest ($self $other -> $output) => $bitor} )?
+1492 $( __impl_operator! {BitXor [$flag] bitxor for &mut $dest ($self $other -> $output) => $bitxor} )?
+1493 };
+1494}
+1495
+1496/// Generates a generic operator
+1497#[doc(hidden)]
+1498#[macro_export]
+1499macro_rules! __impl_operator {
+1500
+1501 // Owned
+1502 ( $op_type:ident [$rhs:ty] $op_lower:ident for $dest:ident ($self:ident $other:ident -> $output:ident) => $block:block ) => {
+1503 impl std::ops::$op_type<$rhs> for $dest {
+1504 type Output = $output;
+1505 fn $op_lower($self, $other: $rhs) -> Self::Output $block
+1506 }
+1507 };
+1508
+1509 // Reference
+1510 ( $op_type:ident [$rhs:ty] $op_lower:ident for & $dest:ident ($self:ident $other:ident -> $output:ident) => $block:block ) => {
+1511 impl std::ops::$op_type<$rhs> for &$dest {
+1512 type Output = $output;
+1513 fn $op_lower($self, $other: $rhs) -> Self::Output $block
+1514 }
+1515 };
+1516
+1517 // Mutable Reference
+1518 ( $op_type:ident [$rhs:ty] $op_lower:ident for &mut $dest:ident ($self:ident $other:ident -> $output:ident) => $block:block ) => {
+1519 impl std::ops::$op_type<$rhs> for &mut $dest {
+1520 type Output = $output;
+1521 fn $op_lower($self, $other: $rhs) -> Self::Output $block
+1522 }
+1523 };
+1524}
+1525
+1526/// Generates a generic assign operator
+1527#[doc(hidden)]
+1528#[macro_export]
+1529macro_rules! __impl_assign_operator {
+1530 ( $op_type:ident [$rhs:ty] $op_lower:ident for $dest:ident ($self:ident $other:ident) => $block:block ) => {
+1531 impl std::ops::$op_type<$rhs> for $dest {
+1532 fn $op_lower(&mut $self, $other: $rhs) $block
+1533 }
+1534 };
+1535}
+1536
+1537// Defaults
+1538
+1539/// Generates a [`Default`] implementation.
+1540#[doc(hidden)]
+1541#[macro_export]
+1542macro_rules! __impl_default {
+1543 ($name:ident => $block:block) => {
+1544 impl Default for $name {
+1545 fn default() -> Self $block
+1546 }
+1547 };
+1548}
+1549
+1550// Converters
+1551
+1552/// Generates a [`From`] implementation.
+1553#[doc(hidden)]
+1554#[macro_export]
+1555macro_rules! __impl_from {
+1556 ($(#[$doc:meta])* $from:ty as $to:ident ($arg:ident) => $block:block) => {
+1557 $(#[$doc])*
+1558 impl From<$from> for $to {
+1559 fn from($arg: $from) -> $to $block
+1560 }
+1561 };
+1562}
+1563
+1564// Formatters
+1565
+1566/// Generates formatter implementations
+1567/// from a set of parameters.
+1568#[doc(hidden)]
+1569#[macro_export(local_inner_macros)]
+1570macro_rules! __impl_formatters {
+1571 ($name:ident ($self:ident $f:ident) { $( $formatter:ident => $block:block )+ } ) => {
+1572 $( __impl_formatter!($formatter for $name ($self $f) => $block); )+
+1573 };
+1574}
+1575
+1576/// Generates a generic formatter implementation.
+1577#[doc(hidden)]
+1578#[macro_export]
+1579macro_rules! __impl_formatter {
+1580 ($formatter:ident for $name:ident ($self:ident $f:ident) => $block:block) => {
+1581 impl std::fmt::$formatter for $name {
+1582 fn fmt(&$self, $f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result $block
+1583 }
+1584 };
+1585}
+1586
+1587// -------------------------------------------------------------------------------------------------
+1588// Example
+1589
+1590#[allow(dead_code)]
+1591#[allow(unused_variables)]
+1592#[cfg(doc)]
+1593pub mod examples {
+1594 //! Examples of generated output using different configurations.
+1595 //!
+1596 //! __This module is only compiled with documentation builds
+1597 //! and will not be available for import.__
+1598 //!
+1599 //! use the [`bitfield`] macro to generate a field struct and flag enum.
+1600 //!
+1601
+1602 #[allow(dead_code)]
+1603 #[allow(unused_variables)]
+1604 #[cfg(doc)]
+1605 pub mod full_example {
+1606 //! Example of generated output, using both a bit field and a flag enum.
+1607 //!
+1608 //! __This module is only compiled with documentation builds
+1609 //! and will not be available for import.__
+1610 //!
+1611 //! use the [`bitfield`] macro to generate a field struct and flag enum.
+1612 //!
+1613 use super::*;
+1614
+1615 bitfield! {
+1616 /// Optional docstring for my example bit field.
+1617 pub u8 ExampleField
+1618 /// Optional docstring for my flag enum.
+1619 ExampleFlags {
+1620 /// Optional docstring for Flag0
+1621 0 : Flag0,
+1622 /// Optional docstring for Flag1
+1623 1 : Flag1,
+1624 /// Optional docstring for Flag2
+1625 2 : Flag2,
+1626 /// Optional docstring for Flag3
+1627 3 : Flag3,
+1628 /// Optional docstring for Flag4
+1629 4 : Flag4,
+1630 /// Optional docstring for Flag5
+1631 5 : Flag5,
+1632 /// Optional docstring for Flag6
+1633 6 : Flag6,
+1634 /// Optional docstring for Flag7
+1635 7 : Flag7,
+1636 }
+1637 }
+1638 }
+1639
+1640 #[allow(dead_code)]
+1641 #[allow(unused_variables)]
+1642 #[cfg(doc)]
+1643 pub mod flagless_example {
+1644 //! Example of generated output, using only a bit field without a flag enum.
+1645 //!
+1646 //! __This module is only compiled with documentation builds
+1647 //! and will not be available for import.__
+1648 //!
+1649 //! use the [`bitfield`] macro to generate a field struct and flag enum.
+1650 //!
+1651 use super::*;
+1652
+1653 bitfield! {
+1654 /// Optional docstring for my example bit field.
+1655 pub u8 ExampleField
+1656 }
+1657 }
+1658}
+1659
+1660// -------------------------------------------------------------------------------------------------
+1661// Tests
+1662
+1663#[allow(dead_code)]
+1664#[allow(unused_variables)]
+1665#[cfg(test)]
+1666mod test {
+1667 use super::*;
+1668 use std::{u128, u16, u32, u64, usize};
+1669
+1670 macro_rules! tests {
+1671 ( $( $name:ident => $block:block )+ ) => {
+1672 $(
+1673 #[test]
+1674 fn $name() $block
+1675 )+
+1676 };
+1677 }
+1678
+1679 bitfield! {
+1680 /// My Test Thing
+1681 u8 MyFieldU8
+1682 MyFlagsU8 {
+1683 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1684 }
+1685 }
+1686
+1687 bitfield! {
+1688 /// My Test Thing
+1689 u16 MyFieldU16
+1690 MyFlagsU16 {
+1691 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1692 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1693 }
+1694 }
+1695
+1696 bitfield! {
+1697 /// My Test Thing
+1698 u32 MyFieldU32
+1699 MyFlagsU32 {
+1700 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1701 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1702 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1703 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1704 }
+1705 }
+1706
+1707 bitfield! {
+1708 /// My Test Thing
+1709 u64 MyFieldU64
+1710 MyFlagsU64 {
+1711 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1712 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1713 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1714 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1715 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
+1716 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
+1717 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
+1718 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
+1719 }
+1720 }
+1721
+1722 bitfield! {
+1723 /// My Test Thing
+1724 u128 MyFieldU128
+1725 MyFlagsU128 {
+1726 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1727 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1728 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1729 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1730 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
+1731 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
+1732 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
+1733 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
+1734 64 : Flag64, 65 : Flag65, 66 : Flag66, 67 : Flag67, 68 : Flag68, 69 : Flag69, 70 : Flag70, 71 : Flag71,
+1735 72 : Flag72, 73 : Flag73, 74 : Flag74, 75 : Flag75, 76 : Flag76, 77 : Flag77, 78 : Flag78, 79 : Flag79,
+1736 80 : Flag80, 81 : Flag81, 82 : Flag82, 83 : Flag83, 84 : Flag84, 85 : Flag85, 86 : Flag86, 87 : Flag87,
+1737 88 : Flag88, 89 : Flag89, 90 : Flag90, 91 : Flag91, 92 : Flag92, 93 : Flag93, 94 : Flag94, 95 : Flag95,
+1738 96 : Flag96, 97 : Flag97, 98 : Flag98, 99 : Flag99, 100 : Flag100, 101 : Flag101, 102 : Flag102, 103 : Flag103,
+1739 104 : Flag104, 105 : Flag105, 106 : Flag106, 107 : Flag107, 108 : Flag108, 109 : Flag109, 110 : Flag110, 111 : Flag111,
+1740 112 : Flag112, 113 : Flag113, 114 : Flag114, 115 : Flag115, 116 : Flag116, 117 : Flag117, 118 : Flag118, 119 : Flag119,
+1741 120 : Flag120, 121 : Flag121, 122 : Flag122, 123 : Flag123, 124 : Flag124, 125 : Flag125, 126 : Flag126, 127 : Flag127,
+1742 }
+1743 }
+1744
+1745 #[cfg(target_pointer_width = "64")]
+1746 bitfield! {
+1747 /// My Test Thing
+1748 usize MyFieldUsize
+1749 MyFlagsUsize {
+1750 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1751 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1752 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1753 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1754 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
+1755 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
+1756 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
+1757 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
+1758 }
+1759 }
+1760
+1761 #[cfg(target_pointer_width = "32")]
+1762 bitfield! {
+1763 /// My Test Thing
+1764 usize MyFieldUsize
+1765 MyFlagsUsize {
+1766 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1767 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1768 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1769 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1770 }
+1771 }
+1772
+1773 bitfield! {
+1774 /// My Test Thing
+1775 u8 MyFieldU8Nf
+1776 MyFlagsU8Nf {
+1777 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1778 }
+1779 }
+1780
+1781 bitfield! {
+1782 /// My Test Thing
+1783 u16 MyFieldU16Nf
+1784 MyFlagsU16Nf {
+1785 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1786 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1787 }
+1788 }
+1789
+1790 bitfield! {
+1791 /// My Test Thing
+1792 u32 MyFieldU32Nf
+1793 MyFlagsU32Nf {
+1794 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1795 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1796 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1797 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1798 }
+1799 }
+1800
+1801 bitfield! {
+1802 /// My Test Thing
+1803 u64 MyFieldU64Nf
+1804 MyFlagsU64Nf {
+1805 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1806 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1807 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1808 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1809 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
+1810 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
+1811 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
+1812 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
+1813 }
+1814 }
+1815
+1816 bitfield! {
+1817 /// My Test Thing
+1818 u128 MyFieldU128Nf
+1819 MyFlagsU128Nf {
+1820 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1821 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1822 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1823 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1824 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
+1825 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
+1826 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
+1827 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
+1828 64 : Flag64, 65 : Flag65, 66 : Flag66, 67 : Flag67, 68 : Flag68, 69 : Flag69, 70 : Flag70, 71 : Flag71,
+1829 72 : Flag72, 73 : Flag73, 74 : Flag74, 75 : Flag75, 76 : Flag76, 77 : Flag77, 78 : Flag78, 79 : Flag79,
+1830 80 : Flag80, 81 : Flag81, 82 : Flag82, 83 : Flag83, 84 : Flag84, 85 : Flag85, 86 : Flag86, 87 : Flag87,
+1831 88 : Flag88, 89 : Flag89, 90 : Flag90, 91 : Flag91, 92 : Flag92, 93 : Flag93, 94 : Flag94, 95 : Flag95,
+1832 96 : Flag96, 97 : Flag97, 98 : Flag98, 99 : Flag99, 100 : Flag100, 101 : Flag101, 102 : Flag102, 103 : Flag103,
+1833 104 : Flag104, 105 : Flag105, 106 : Flag106, 107 : Flag107, 108 : Flag108, 109 : Flag109, 110 : Flag110, 111 : Flag111,
+1834 112 : Flag112, 113 : Flag113, 114 : Flag114, 115 : Flag115, 116 : Flag116, 117 : Flag117, 118 : Flag118, 119 : Flag119,
+1835 120 : Flag120, 121 : Flag121, 122 : Flag122, 123 : Flag123, 124 : Flag124, 125 : Flag125, 126 : Flag126, 127 : Flag127,
+1836 }
+1837 }
+1838
+1839 #[cfg(target_pointer_width = "64")]
+1840 bitfield! {
+1841 /// My Test Thing
+1842 usize MyFieldUsizeNf
+1843 MyFlagsUsizeNf {
+1844 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1845 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1846 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1847 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1848 32 : Flag32, 33 : Flag33, 34 : Flag34, 35 : Flag35, 36 : Flag36, 37 : Flag37, 38 : Flag38, 39 : Flag39,
+1849 40 : Flag40, 41 : Flag41, 42 : Flag42, 43 : Flag43, 44 : Flag44, 45 : Flag45, 46 : Flag46, 47 : Flag47,
+1850 48 : Flag48, 49 : Flag49, 50 : Flag50, 51 : Flag51, 52 : Flag52, 53 : Flag53, 54 : Flag54, 55 : Flag55,
+1851 56 : Flag56, 57 : Flag57, 58 : Flag58, 59 : Flag59, 60 : Flag60, 61 : Flag61, 62 : Flag62, 63 : Flag63,
+1852 }
+1853 }
+1854
+1855 #[cfg(target_pointer_width = "32")]
+1856 bitfield! {
+1857 /// My Test Thing
+1858 usize MyFieldUsizeNf
+1859 MyFlagsUsizeNf {
+1860 0 : Flag0, 1 : Flag1, 2 : Flag2, 3 : Flag3, 4 : Flag4, 5 : Flag5, 6 : Flag6, 7 : Flag7,
+1861 8 : Flag8, 9 : Flag9, 10 : Flag10, 11 : Flag11, 12 : Flag12, 13 : Flag13, 14 : Flag14, 15 : Flag15,
+1862 16 : Flag16, 17 : Flag17, 18 : Flag18, 19 : Flag19, 20 : Flag20, 21 : Flag21, 22 : Flag22, 23 : Flag23,
+1863 24 : Flag24, 25 : Flag25, 26 : Flag26, 27 : Flag27, 28 : Flag28, 29 : Flag29, 30 : Flag30, 31 : Flag31,
+1864 }
+1865 }
+1866
+1867 const U8: u8 = 123;
+1868 const B8: &str = "01111011";
+1869 const U16: u16 = 51526;
+1870 const B16: &str = "1100100101000110";
+1871 const U32: u32 = 2828091834;
+1872 const B32: &str = "10101000100100010100000110111010";
+1873 const U64: u64 = 18325744043706550615;
+1874 const B64: &str = "1111111001010010000111110001110100100001110111000000100101010111";
+1875 const U128: u128 = 160140183460469230739687303714882104727;
+1876 const B128: &str = "01111000011110011110000010100001011000111110000100101011010111011111111110000110011101100010110100100000110001101010110110010111";
+1877
+1878 #[cfg(target_pointer_width = "64")]
+1879 const USIZE: usize = 18325744043706550615;
+1880 #[cfg(target_pointer_width = "64")]
+1881 const BSIZE: &str = "1111111001010010000111110001110100100001110111000000100101010111";
+1882
+1883 #[cfg(target_pointer_width = "32")]
+1884 const USIZE: usize = 2828091834;
+1885 #[cfg(target_pointer_width = "32")]
+1886 const BSIZE: &str = "10101000100100010100000110111010";
+1887
+1888 // constructors
+1889 tests! {
+1890 new_u8 => {
+1891 MyFieldU8(U8);
+1892 }
+1893 new_u16 => {
+1894 MyFieldU16(U16);
+1895 }
+1896 new_u32 => {
+1897 MyFieldU32(U32);
+1898 }
+1899 new_u64 => {
+1900 MyFieldU64(U64);
+1901 }
+1902 new_u128 => {
+1903 MyFieldU128(U128);
+1904 }
+1905 new_usize => {
+1906 MyFieldUsize(USIZE);
+1907 }
+1908 }
+1909
+1910 // from binary str
+1911 tests! {
+1912 from_binary_str_u8 => {
+1913 assert_eq!(MyFieldU8::from_binary_str(B8), MyFieldU8(U8));
+1914 }
+1915 from_binary_str_u16 => {
+1916 assert_eq!(MyFieldU16::from_binary_str(B16), MyFieldU16(U16));
+1917 }
+1918 from_binary_str_u32 => {
+1919 assert_eq!(MyFieldU32::from_binary_str(B32), MyFieldU32(U32));
+1920 }
+1921 from_binary_str_u64 => {
+1922 assert_eq!(MyFieldU64::from_binary_str(B64), MyFieldU64(U64));
+1923 }
+1924 from_binary_str_u128 => {
+1925 assert_eq!(MyFieldU128::from_binary_str(B128), MyFieldU128(U128));
+1926 }
+1927 from_binary_str_usize => {
+1928 assert_eq!(MyFieldUsize::from_binary_str(BSIZE), MyFieldUsize(USIZE));
+1929 }
+1930 }
+1931
+1932 // from binary string
+1933 tests! {
+1934 from_binary_string_u8 => {
+1935 assert_eq!(MyFieldU8::from_binary_string(String::from(B8)), MyFieldU8(U8));
+1936 }
+1937 from_binary_string_u16 => {
+1938 assert_eq!(MyFieldU16::from_binary_string(String::from(B16)), MyFieldU16(U16));
+1939 }
+1940 from_binary_string_u32 => {
+1941 assert_eq!(MyFieldU32::from_binary_string(String::from(B32)), MyFieldU32(U32));
+1942 }
+1943 from_binary_string_u64 => {
+1944 assert_eq!(MyFieldU64::from_binary_string(String::from(B64)), MyFieldU64(U64));
+1945 }
+1946 from_binary_string_u128 => {
+1947 assert_eq!(MyFieldU128::from_binary_string(String::from(B128)), MyFieldU128(U128));
+1948 }
+1949 from_binary_string_usize => {
+1950 assert_eq!(MyFieldUsize::from_binary_string(String::from(BSIZE)), MyFieldUsize(USIZE));
+1951 }
+1952 }
+1953
+1954 // ones
+1955 tests! {
+1956 ones_u8 => {
+1957 assert_eq!(MyFieldU8::ones(), MyFieldU8(u8::MAX));
+1958 }
+1959 ones_u16 => {
+1960 assert_eq!(MyFieldU16::ones(), MyFieldU16(u16::MAX));
+1961 }
+1962 ones_u32 => {
+1963 assert_eq!(MyFieldU32::ones(), MyFieldU32(u32::MAX));
+1964 }
+1965 ones_u64 => {
+1966 assert_eq!(MyFieldU64::ones(), MyFieldU64(u64::MAX));
+1967 }
+1968 ones_u128 => {
+1969 assert_eq!(MyFieldU128::ones(), MyFieldU128(u128::MAX));
+1970 }
+1971 ones_usize => {
+1972 assert_eq!(MyFieldUsize::ones(), MyFieldUsize(usize::MAX));
+1973 }
+1974 }
+1975
+1976 // zeros
+1977 tests! {
+1978 zeros_u8 => {
+1979 assert_eq!(MyFieldU8::zeros(), MyFieldU8(0));
+1980 }
+1981 zeros_u16 => {
+1982 assert_eq!(MyFieldU16::zeros(), MyFieldU16(0));
+1983 }
+1984 zeros_u32 => {
+1985 assert_eq!(MyFieldU32::zeros(), MyFieldU32(0));
+1986 }
+1987 zeros_u64 => {
+1988 assert_eq!(MyFieldU64::zeros(), MyFieldU64(0));
+1989 }
+1990 zeros_u128 => {
+1991 assert_eq!(MyFieldU128::zeros(), MyFieldU128(0));
+1992 }
+1993 zeros_usize => {
+1994 assert_eq!(MyFieldUsize::zeros(), MyFieldUsize(0));
+1995 }
+1996 }
+1997
+1998 // defaults
+1999 tests! {
+2000 default_u8 => {
+2001 assert_eq!(0, MyFieldU8::default().as_integer())
+2002 }
+2003 default_u16 => {
+2004 assert_eq!(0, MyFieldU16::default().as_integer())
+2005 }
+2006 default_u32 => {
+2007 assert_eq!(0, MyFieldU32::default().as_integer())
+2008 }
+2009 default_u64 => {
+2010 assert_eq!(0, MyFieldU64::default().as_integer())
+2011 }
+2012 default_u128 => {
+2013 assert_eq!(0, MyFieldU128::default().as_integer())
+2014 }
+2015 default_usize => {
+2016 assert_eq!(0, MyFieldUsize::default().as_integer())
+2017 }
+2018 }
+2019
+2020 // bit count
+2021 tests! {
+2022 bit_count_u8 => {
+2023 let field = MyFieldU8(U8);
+2024 assert_eq!(u8::BITS as usize, MyFieldU8::BITS)
+2025 }
+2026 bit_count_u16 => {
+2027 let field = MyFieldU16(U16);
+2028 assert_eq!(u16::BITS as usize, MyFieldU16::BITS)
+2029 }
+2030 bit_count_u32 => {
+2031 let field = MyFieldU32(U32);
+2032 assert_eq!(u32::BITS as usize, MyFieldU32::BITS)
+2033 }
+2034 bit_count_u64 => {
+2035 let field = MyFieldU64(U64);
+2036 assert_eq!(u64::BITS as usize, MyFieldU64::BITS)
+2037 }
+2038 bit_count_u128 => {
+2039 let field = MyFieldU128(U128);
+2040 assert_eq!(u128::BITS as usize, MyFieldU128::BITS)
+2041 }
+2042 bit_count_usize => {
+2043 let field = MyFieldUsize(USIZE);
+2044 assert_eq!(usize::BITS as usize, MyFieldUsize::BITS)
+2045 }
+2046 }
+2047
+2048 // byte count
+2049 tests! {
+2050 byte_count_u8 => {
+2051 let field = MyFieldU8(U8);
+2052 assert_eq!(1, MyFieldU8::BYTES)
+2053 }
+2054 byte_count_u16 => {
+2055 let field = MyFieldU16(U16);
+2056 assert_eq!(2, MyFieldU16::BYTES)
+2057 }
+2058 byte_count_u32 => {
+2059 let field = MyFieldU32(U32);
+2060 assert_eq!(4, MyFieldU32::BYTES)
+2061 }
+2062 byte_count_u64 => {
+2063 let field = MyFieldU64(U64);
+2064 assert_eq!(8, MyFieldU64::BYTES)
+2065 }
+2066 byte_count_u128 => {
+2067 let field = MyFieldU128(U128);
+2068 assert_eq!(16, MyFieldU128::BYTES)
+2069 }
+2070 byte_count_usize => {
+2071 let field = MyFieldUsize(USIZE);
+2072 assert_eq!((usize::BITS as usize) / 8, MyFieldUsize::BYTES)
+2073 }
+2074 }
+2075
+2076 // integer value
+2077 tests! {
+2078 integer_u8 => {
+2079 let field = MyFieldU8(U8);
+2080 assert_eq!(U8, field.as_integer())
+2081 }
+2082 integer_u16 => {
+2083 let field = MyFieldU16(U16);
+2084 assert_eq!(U16, field.as_integer())
+2085 }
+2086 integer_u32 => {
+2087 let field = MyFieldU32(U32);
+2088 assert_eq!(U32, field.as_integer())
+2089 }
+2090 integer_u64 => {
+2091 let field = MyFieldU64(U64);
+2092 assert_eq!(U64, field.as_integer())
+2093 }
+2094 integer_u128 => {
+2095 let field = MyFieldU128(U128);
+2096 assert_eq!(U128, field.as_integer())
+2097 }
+2098 integer_usize => {
+2099 let field = MyFieldUsize(USIZE);
+2100 assert_eq!(USIZE, field.as_integer())
+2101 }
+2102 }
+2103
+2104 // binary value
+2105 tests! {
+2106 binary_u8 => {
+2107 let field = MyFieldU8(U8);
+2108 assert_eq!(B8, field.as_binary())
+2109 }
+2110 binary_u16 => {
+2111 let field = MyFieldU16(U16);
+2112 assert_eq!(B16, field.as_binary())
+2113 }
+2114 binary_u32 => {
+2115 let field = MyFieldU32(U32);
+2116 assert_eq!(B32, field.as_binary())
+2117 }
+2118 binary_u64 => {
+2119 let field = MyFieldU64(U64);
+2120 assert_eq!(B64, field.as_binary())
+2121 }
+2122 binary_u128 => {
+2123 let field = MyFieldU128(U128);
+2124 assert_eq!(B128, field.as_binary())
+2125 }
+2126 binary_usize => {
+2127 let field = MyFieldUsize(USIZE);
+2128 assert_eq!(BSIZE, field.as_binary())
+2129 }
+2130 }
+2131
+2132 // get index
+2133 tests! {
+2134 get_index_u8 => {
+2135 let field = MyFieldU8(U8);
+2136 for (index, char) in B8.chars().rev().enumerate() {
+2137 if char == '1' {
+2138 assert!(field.get_index(index as u8))
+2139 } else if char == '0' {
+2140 assert!(!field.get_index(index as u8))
+2141 } else {
+2142 panic!("invalid char in binary string")
+2143 }
+2144 }
+2145 }
+2146 get_index_u16 => {
+2147 let field = MyFieldU16(U16);
+2148 for (index, char) in B16.chars().rev().enumerate() {
+2149 if char == '1' {
+2150 assert!(field.get_index(index as u8))
+2151 } else if char == '0' {
+2152 assert!(!field.get_index(index as u8))
+2153 } else {
+2154 panic!("invalid char in binary string")
+2155 }
+2156 }
+2157 }
+2158 get_index_u32 => {
+2159 let field = MyFieldU32(U32);
+2160 for (index, char) in B32.chars().rev().enumerate() {
+2161 if char == '1' {
+2162 assert!(field.get_index(index as u8))
+2163 } else if char == '0' {
+2164 assert!(!field.get_index(index as u8))
+2165 } else {
+2166 panic!("invalid char in binary string")
+2167 }
+2168 }
+2169 }
+2170 get_index_u64 => {
+2171 let field = MyFieldU64(U64);
+2172 for (index, char) in B64.chars().rev().enumerate() {
+2173 if char == '1' {
+2174 assert!(field.get_index(index as u8))
+2175 } else if char == '0' {
+2176 assert!(!field.get_index(index as u8))
+2177 } else {
+2178 panic!("invalid char in binary string")
+2179 }
+2180 }
+2181 }
+2182 get_index_u128 => {
+2183 let field = MyFieldU128(U128);
+2184 for (index, char) in B128.chars().rev().enumerate() {
+2185 if char == '1' {
+2186 assert!(field.get_index(index as u8))
+2187 } else if char == '0' {
+2188 assert!(!field.get_index(index as u8))
+2189 } else {
+2190 panic!("invalid char in binary string")
+2191 }
+2192 }
+2193 }
+2194 get_index_usize => {
+2195 let field = MyFieldUsize(USIZE);
+2196 for (index, char) in BSIZE.chars().rev().enumerate() {
+2197 if char == '1' {
+2198 assert!(field.get_index(index as u8))
+2199 } else if char == '0' {
+2200 assert!(!field.get_index(index as u8))
+2201 } else {
+2202 panic!("invalid char in binary string")
+2203 }
+2204 }
+2205 }
+2206 }
+2207
+2208 // set index
+2209 tests! {
+2210 set_index_u8 => {
+2211 let mut field = MyFieldU8(0);
+2212 for (index, char) in B8.chars().rev().enumerate() {
+2213 field.set_index(index as u8);
+2214 for (s_index, _char) in B8.chars().rev().enumerate() {
+2215 if s_index <= index {
+2216 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2217 } else {
+2218 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2219 }
+2220 }
+2221 }
+2222 }
+2223 set_index_u16 => {
+2224 let mut field = MyFieldU16(0);
+2225 for (index, char) in B16.chars().rev().enumerate() {
+2226 field.set_index(index as u8);
+2227 for (s_index, _char) in B16.chars().rev().enumerate() {
+2228 if s_index <= index {
+2229 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2230 } else {
+2231 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2232 }
+2233 }
+2234 }
+2235 }
+2236 set_index_u32 => {
+2237 let mut field = MyFieldU32(0);
+2238 for (index, char) in B32.chars().rev().enumerate() {
+2239 field.set_index(index as u8);
+2240 for (s_index, _char) in B32.chars().rev().enumerate() {
+2241 if s_index <= index {
+2242 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2243 } else {
+2244 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2245 }
+2246 }
+2247 }
+2248 }
+2249 set_index_u64 => {
+2250 let mut field = MyFieldU64(0);
+2251 for (index, char) in B64.chars().rev().enumerate() {
+2252 field.set_index(index as u8);
+2253 for (s_index, _char) in B64.chars().rev().enumerate() {
+2254 if s_index <= index {
+2255 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2256 } else {
+2257 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2258 }
+2259 }
+2260 }
+2261 }
+2262 set_index_u128 => {
+2263 let mut field = MyFieldU128(0);
+2264 for (index, char) in B128.chars().rev().enumerate() {
+2265 field.set_index(index as u8);
+2266 for (s_index, _char) in B128.chars().rev().enumerate() {
+2267 if s_index <= index {
+2268 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2269 } else {
+2270 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2271 }
+2272 }
+2273 }
+2274 }
+2275 set_index_usize => {
+2276 let mut field = MyFieldUsize(0);
+2277 for (index, char) in BSIZE.chars().rev().enumerate() {
+2278 field.set_index(index as u8);
+2279 for (s_index, _char) in BSIZE.chars().rev().enumerate() {
+2280 if s_index <= index {
+2281 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2282 } else {
+2283 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2284 }
+2285 }
+2286 }
+2287 }
+2288 }
+2289
+2290 // clear index
+2291 tests! {
+2292 clear_index_u8 => {
+2293 let mut field = MyFieldU8(u8::MAX);
+2294 for (index, char) in B8.chars().rev().enumerate() {
+2295 assert!(field.get_index(index as u8), "{:#?}", field);
+2296 field.clear_index(index as u8);
+2297 for (s_index, _char) in B8.chars().rev().enumerate() {
+2298 if s_index <= index {
+2299 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2300 } else {
+2301 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2302 }
+2303 }
+2304 }
+2305 }
+2306 clear_index_u16 => {
+2307 let mut field = MyFieldU16(u16::MAX);
+2308 for (index, char) in B16.chars().rev().enumerate() {
+2309 assert!(field.get_index(index as u8), "{:#?}", field);
+2310 field.clear_index(index as u8);
+2311 for (s_index, _char) in B16.chars().rev().enumerate() {
+2312 if s_index <= index {
+2313 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2314 } else {
+2315 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2316 }
+2317 }
+2318 }
+2319 }
+2320 clear_index_u32 => {
+2321 let mut field = MyFieldU32(u32::MAX);
+2322 for (index, char) in B32.chars().rev().enumerate() {
+2323 assert!(field.get_index(index as u8), "{:#?}", field);
+2324 field.clear_index(index as u8);
+2325 for (s_index, _char) in B32.chars().rev().enumerate() {
+2326 if s_index <= index {
+2327 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2328 } else {
+2329 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2330 }
+2331 }
+2332 }
+2333 }
+2334 clear_index_u64 => {
+2335 let mut field = MyFieldU64(u64::MAX);
+2336 for (index, char) in B64.chars().rev().enumerate() {
+2337 assert!(field.get_index(index as u8), "{:#?}", field);
+2338 field.clear_index(index as u8);
+2339 for (s_index, _char) in B64.chars().rev().enumerate() {
+2340 if s_index <= index {
+2341 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2342 } else {
+2343 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2344 }
+2345 }
+2346 }
+2347 }
+2348 clear_index_u128 => {
+2349 let mut field = MyFieldU128(u128::MAX);
+2350 for (index, char) in B128.chars().rev().enumerate() {
+2351 assert!(field.get_index(index as u8), "{:#?}", field);
+2352 field.clear_index(index as u8);
+2353 for (s_index, _char) in B128.chars().rev().enumerate() {
+2354 if s_index <= index {
+2355 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2356 } else {
+2357 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2358 }
+2359 }
+2360 }
+2361 }
+2362 clear_index_usize => {
+2363 let mut field = MyFieldUsize(usize::MAX);
+2364 for (index, char) in BSIZE.chars().rev().enumerate() {
+2365 assert!(field.get_index(index as u8), "{:#?}", field);
+2366 field.clear_index(index as u8);
+2367 for (s_index, _char) in BSIZE.chars().rev().enumerate() {
+2368 if s_index <= index {
+2369 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2370 } else {
+2371 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2372 }
+2373 }
+2374 }
+2375 }
+2376 }
+2377
+2378 // toggle index
+2379 tests! {
+2380 toggle_index_u8 => {
+2381 let mut field = MyFieldU8(U8);
+2382 for (index, char) in B8.chars().rev().enumerate() {
+2383 if char == '1' {
+2384 assert!(field.get_index(index as u8));
+2385 field.toggle_index(index as u8);
+2386 assert!(!field.get_index(index as u8));
+2387 } else if char == '0' {
+2388 assert!(!field.get_index(index as u8));
+2389 field.toggle_index(index as u8);
+2390 assert!(field.get_index(index as u8));
+2391 } else {
+2392 panic!("invalid char in binary string");
+2393 }
+2394 }
+2395 }
+2396 toggle_index_u16 => {
+2397 let mut field = MyFieldU16(U16);
+2398 for (index, char) in B16.chars().rev().enumerate() {
+2399 if char == '1' {
+2400 assert!(field.get_index(index as u8));
+2401 field.toggle_index(index as u8);
+2402 assert!(!field.get_index(index as u8));
+2403 } else if char == '0' {
+2404 assert!(!field.get_index(index as u8));
+2405 field.toggle_index(index as u8);
+2406 assert!(field.get_index(index as u8));
+2407 } else {
+2408 panic!("invalid char in binary string")
+2409 }
+2410 }
+2411 }
+2412 toggle_index_u32 => {
+2413 let mut field = MyFieldU32(U32);
+2414 for (index, char) in B32.chars().rev().enumerate() {
+2415 if char == '1' {
+2416 assert!(field.get_index(index as u8));
+2417 field.toggle_index(index as u8);
+2418 assert!(!field.get_index(index as u8));
+2419 } else if char == '0' {
+2420 assert!(!field.get_index(index as u8));
+2421 field.toggle_index(index as u8);
+2422 assert!(field.get_index(index as u8));
+2423 } else {
+2424 panic!("invalid char in binary string")
+2425 }
+2426 }
+2427 }
+2428 toggle_index_u64 => {
+2429 let mut field = MyFieldU64(U64);
+2430 for (index, char) in B64.chars().rev().enumerate() {
+2431 if char == '1' {
+2432 assert!(field.get_index(index as u8));
+2433 field.toggle_index(index as u8);
+2434 assert!(!field.get_index(index as u8));
+2435 } else if char == '0' {
+2436 assert!(!field.get_index(index as u8));
+2437 field.toggle_index(index as u8);
+2438 assert!(field.get_index(index as u8));
+2439 } else {
+2440 panic!("invalid char in binary string")
+2441 }
+2442 }
+2443 }
+2444 toggle_index_u128 => {
+2445 let mut field = MyFieldU128(U128);
+2446 for (index, char) in B128.chars().rev().enumerate() {
+2447 if char == '1' {
+2448 assert!(field.get_index(index as u8));
+2449 field.toggle_index(index as u8);
+2450 assert!(!field.get_index(index as u8));
+2451 } else if char == '0' {
+2452 assert!(!field.get_index(index as u8));
+2453 field.toggle_index(index as u8);
+2454 assert!(field.get_index(index as u8));
+2455 } else {
+2456 panic!("invalid char in binary string")
+2457 }
+2458 }
+2459 }
+2460 toggle_index_usize => {
+2461 let mut field = MyFieldUsize(USIZE);
+2462 for (index, char) in BSIZE.chars().rev().enumerate() {
+2463 if char == '1' {
+2464 assert!(field.get_index(index as u8));
+2465 field.toggle_index(index as u8);
+2466 assert!(!field.get_index(index as u8));
+2467 } else if char == '0' {
+2468 assert!(!field.get_index(index as u8));
+2469 field.toggle_index(index as u8);
+2470 assert!(field.get_index(index as u8));
+2471 } else {
+2472 panic!("invalid char in binary string")
+2473 }
+2474 }
+2475 }
+2476 }
+2477
+2478 // get
+2479 tests! {
+2480 get_u8 => {
+2481 let field = MyFieldU8(U8);
+2482 for (index, char) in B8.chars().rev().enumerate() {
+2483 if char == '1' {
+2484 assert!(field.get(MyFlagsU8::from(index as u8)))
+2485 } else if char == '0' {
+2486 assert!(!field.get(MyFlagsU8::from(index as u8)))
+2487 } else {
+2488 panic!("invalid char in binary string")
+2489 }
+2490 }
+2491 }
+2492 get_u16 => {
+2493 let field = MyFieldU16(U16);
+2494 for (index, char) in B16.chars().rev().enumerate() {
+2495 if char == '1' {
+2496 assert!(field.get(MyFlagsU16::from(index as u8)))
+2497 } else if char == '0' {
+2498 assert!(!field.get(MyFlagsU16::from(index as u8)))
+2499 } else {
+2500 panic!("invalid char in binary string")
+2501 }
+2502 }
+2503 }
+2504 get_u32 => {
+2505 let field = MyFieldU32(U32);
+2506 for (index, char) in B32.chars().rev().enumerate() {
+2507 if char == '1' {
+2508 assert!(field.get(MyFlagsU32::from(index as u8)))
+2509 } else if char == '0' {
+2510 assert!(!field.get(MyFlagsU32::from(index as u8)))
+2511 } else {
+2512 panic!("invalid char in binary string")
+2513 }
+2514 }
+2515 }
+2516 get_u64 => {
+2517 let field = MyFieldU64(U64);
+2518 for (index, char) in B64.chars().rev().enumerate() {
+2519 if char == '1' {
+2520 assert!(field.get(MyFlagsU64::from(index as u8)))
+2521 } else if char == '0' {
+2522 assert!(!field.get(MyFlagsU64::from(index as u8)))
+2523 } else {
+2524 panic!("invalid char in binary string")
+2525 }
+2526 }
+2527 }
+2528 get_u128 => {
+2529 let field = MyFieldU128(U128);
+2530 for (index, char) in B128.chars().rev().enumerate() {
+2531 if char == '1' {
+2532 assert!(field.get(MyFlagsU128::from(index as u8)))
+2533 } else if char == '0' {
+2534 assert!(!field.get(MyFlagsU128::from(index as u8)))
+2535 } else {
+2536 panic!("invalid char in binary string")
+2537 }
+2538 }
+2539 }
+2540 get_usize => {
+2541 let field = MyFieldUsize(USIZE);
+2542 for (index, char) in BSIZE.chars().rev().enumerate() {
+2543 if char == '1' {
+2544 assert!(field.get(MyFlagsUsize::from(index as u8)))
+2545 } else if char == '0' {
+2546 assert!(!field.get(MyFlagsUsize::from(index as u8)))
+2547 } else {
+2548 panic!("invalid char in binary string")
+2549 }
+2550 }
+2551 }
+2552 }
+2553
+2554 // set
+2555 tests! {
+2556 set_u8 => {
+2557 let mut field = MyFieldU8(0);
+2558 for (index, char) in B8.chars().rev().enumerate() {
+2559 field.set(MyFlagsU8::from(index as u8));
+2560 for (s_index, _char) in B8.chars().rev().enumerate() {
+2561 if s_index <= index {
+2562 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2563 } else {
+2564 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2565 }
+2566 }
+2567 }
+2568 }
+2569 set_u16 => {
+2570 let mut field = MyFieldU16(0);
+2571 for (index, char) in B16.chars().rev().enumerate() {
+2572 field.set(MyFlagsU16::from(index as u8));
+2573 for (s_index, _char) in B16.chars().rev().enumerate() {
+2574 if s_index <= index {
+2575 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2576 } else {
+2577 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2578 }
+2579 }
+2580 }
+2581 }
+2582 set_u32 => {
+2583 let mut field = MyFieldU32(0);
+2584 for (index, char) in B32.chars().rev().enumerate() {
+2585 field.set(MyFlagsU32::from(index as u8));
+2586 for (s_index, _char) in B32.chars().rev().enumerate() {
+2587 if s_index <= index {
+2588 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2589 } else {
+2590 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2591 }
+2592 }
+2593 }
+2594 }
+2595 set_u64 => {
+2596 let mut field = MyFieldU64(0);
+2597 for (index, char) in B64.chars().rev().enumerate() {
+2598 field.set(MyFlagsU64::from(index as u8));
+2599 for (s_index, _char) in B64.chars().rev().enumerate() {
+2600 if s_index <= index {
+2601 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2602 } else {
+2603 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2604 }
+2605 }
+2606 }
+2607 }
+2608 set_u128 => {
+2609 let mut field = MyFieldU128(0);
+2610 for (index, char) in B128.chars().rev().enumerate() {
+2611 field.set(MyFlagsU128::from(index as u8));
+2612 for (s_index, _char) in B128.chars().rev().enumerate() {
+2613 if s_index <= index {
+2614 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2615 } else {
+2616 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2617 }
+2618 }
+2619 }
+2620 }
+2621 set_usize => {
+2622 let mut field = MyFieldUsize(0);
+2623 for (index, char) in BSIZE.chars().rev().enumerate() {
+2624 field.set(MyFlagsUsize::from(index as u8));
+2625 for (s_index, _char) in BSIZE.chars().rev().enumerate() {
+2626 if s_index <= index {
+2627 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2628 } else {
+2629 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2630 }
+2631 }
+2632 }
+2633 }
+2634 }
+2635
+2636 // clear
+2637 tests! {
+2638 clear_u8 => {
+2639 let mut field = MyFieldU8(u8::MAX);
+2640 for (index, char) in B8.chars().rev().enumerate() {
+2641 assert!(field.get_index(index as u8), "{:#?}", field);
+2642 field.clear(MyFlagsU8::from(index as u8));
+2643 for (s_index, _char) in B8.chars().rev().enumerate() {
+2644 if s_index <= index {
+2645 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2646 } else {
+2647 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2648 }
+2649 }
+2650 }
+2651 }
+2652 clear_u16 => {
+2653 let mut field = MyFieldU16(u16::MAX);
+2654 for (index, char) in B16.chars().rev().enumerate() {
+2655 assert!(field.get_index(index as u8), "{:#?}", field);
+2656 field.clear(MyFlagsU16::from(index as u8));
+2657 for (s_index, _char) in B16.chars().rev().enumerate() {
+2658 if s_index <= index {
+2659 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2660 } else {
+2661 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2662 }
+2663 }
+2664 }
+2665 }
+2666 clear_u32 => {
+2667 let mut field = MyFieldU32(u32::MAX);
+2668 for (index, char) in B32.chars().rev().enumerate() {
+2669 assert!(field.get_index(index as u8), "{:#?}", field);
+2670 field.clear(MyFlagsU32::from(index as u8));
+2671 for (s_index, _char) in B32.chars().rev().enumerate() {
+2672 if s_index <= index {
+2673 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2674 } else {
+2675 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2676 }
+2677 }
+2678 }
+2679 }
+2680 clear_u64 => {
+2681 let mut field = MyFieldU64(u64::MAX);
+2682 for (index, char) in B64.chars().rev().enumerate() {
+2683 assert!(field.get_index(index as u8), "{:#?}", field);
+2684 field.clear(MyFlagsU64::from(index as u8));
+2685 for (s_index, _char) in B64.chars().rev().enumerate() {
+2686 if s_index <= index {
+2687 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2688 } else {
+2689 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2690 }
+2691 }
+2692 }
+2693 }
+2694 clear_u128 => {
+2695 let mut field = MyFieldU128(u128::MAX);
+2696 for (index, char) in B128.chars().rev().enumerate() {
+2697 assert!(field.get_index(index as u8), "{:#?}", field);
+2698 field.clear(MyFlagsU128::from(index as u8));
+2699 for (s_index, _char) in B128.chars().rev().enumerate() {
+2700 if s_index <= index {
+2701 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2702 } else {
+2703 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2704 }
+2705 }
+2706 }
+2707 }
+2708 clear_usize => {
+2709 let mut field = MyFieldUsize(usize::MAX);
+2710 for (index, char) in BSIZE.chars().rev().enumerate() {
+2711 assert!(field.get_index(index as u8), "{:#?}", field);
+2712 field.clear(MyFlagsUsize::from(index as u8));
+2713 for (s_index, _char) in BSIZE.chars().rev().enumerate() {
+2714 if s_index <= index {
+2715 assert!(!field.get_index(s_index as u8), "{:#?}", field);
+2716 } else {
+2717 assert!(field.get_index(s_index as u8), "{:#?}", field);
+2718 }
+2719 }
+2720 }
+2721 }
+2722 }
+2723
+2724 // toggle
+2725 tests! {
+2726 toggle_u8 => {
+2727 let mut field = MyFieldU8(U8);
+2728 for (index, char) in B8.chars().rev().enumerate() {
+2729 if char == '1' {
+2730 assert!(field.get_index(index as u8));
+2731 field.toggle(MyFlagsU8::from(index as u8));
+2732 assert!(!field.get_index(index as u8));
+2733 } else if char == '0' {
+2734 assert!(!field.get_index(index as u8));
+2735 field.toggle(MyFlagsU8::from(index as u8));
+2736 assert!(field.get_index(index as u8));
+2737 } else {
+2738 panic!("invalid char in binary string");
+2739 }
+2740 }
+2741 }
+2742 toggle_u16 => {
+2743 let mut field = MyFieldU16(U16);
+2744 for (index, char) in B16.chars().rev().enumerate() {
+2745 if char == '1' {
+2746 assert!(field.get_index(index as u8));
+2747 field.toggle(MyFlagsU16::from(index as u8));
+2748 assert!(!field.get_index(index as u8));
+2749 } else if char == '0' {
+2750 assert!(!field.get_index(index as u8));
+2751 field.toggle(MyFlagsU16::from(index as u8));
+2752 assert!(field.get_index(index as u8));
+2753 } else {
+2754 panic!("invalid char in binary string")
+2755 }
+2756 }
+2757 }
+2758 toggle_u32 => {
+2759 let mut field = MyFieldU32(U32);
+2760 for (index, char) in B32.chars().rev().enumerate() {
+2761 if char == '1' {
+2762 assert!(field.get_index(index as u8));
+2763 field.toggle(MyFlagsU32::from(index as u8));
+2764 assert!(!field.get_index(index as u8));
+2765 } else if char == '0' {
+2766 assert!(!field.get_index(index as u8));
+2767 field.toggle(MyFlagsU32::from(index as u8));
+2768 assert!(field.get_index(index as u8));
+2769 } else {
+2770 panic!("invalid char in binary string")
+2771 }
+2772 }
+2773 }
+2774 toggle_u64 => {
+2775 let mut field = MyFieldU64(U64);
+2776 for (index, char) in B64.chars().rev().enumerate() {
+2777 if char == '1' {
+2778 assert!(field.get_index(index as u8));
+2779 field.toggle(MyFlagsU64::from(index as u8));
+2780 assert!(!field.get_index(index as u8));
+2781 } else if char == '0' {
+2782 assert!(!field.get_index(index as u8));
+2783 field.toggle(MyFlagsU64::from(index as u8));
+2784 assert!(field.get_index(index as u8));
+2785 } else {
+2786 panic!("invalid char in binary string")
+2787 }
+2788 }
+2789 }
+2790 toggle_u128 => {
+2791 let mut field = MyFieldU128(U128);
+2792 for (index, char) in B128.chars().rev().enumerate() {
+2793 if char == '1' {
+2794 assert!(field.get_index(index as u8));
+2795 field.toggle(MyFlagsU128::from(index as u8));
+2796 assert!(!field.get_index(index as u8));
+2797 } else if char == '0' {
+2798 assert!(!field.get_index(index as u8));
+2799 field.toggle(MyFlagsU128::from(index as u8));
+2800 assert!(field.get_index(index as u8));
+2801 } else {
+2802 panic!("invalid char in binary string")
+2803 }
+2804 }
+2805 }
+2806 toggle_usize => {
+2807 let mut field = MyFieldUsize(USIZE);
+2808 for (index, char) in BSIZE.chars().rev().enumerate() {
+2809 if char == '1' {
+2810 assert!(field.get_index(index as u8));
+2811 field.toggle(MyFlagsUsize::from(index as u8));
+2812 assert!(!field.get_index(index as u8));
+2813 } else if char == '0' {
+2814 assert!(!field.get_index(index as u8));
+2815 field.toggle(MyFlagsUsize::from(index as u8));
+2816 assert!(field.get_index(index as u8));
+2817 } else {
+2818 panic!("invalid char in binary string")
+2819 }
+2820 }
+2821 }
+2822 }
+2823
+2824 // diff
+2825 tests! {
+2826 diff_u8 => {
+2827 let field = MyFieldU8(U8);
+2828 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2829 let out = field.diff(reversed);
+2830 assert_eq!("10100101", out.as_binary());
+2831 assert_eq!(165, out.as_integer());
+2832 }
+2833 diff_u16 => {
+2834 let field = MyFieldU16(U16);
+2835 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2836 let out = field.diff(reversed);
+2837 assert_eq!("1010101111010101", out.as_binary());
+2838 assert_eq!(43989, out.as_integer());
+2839 }
+2840 diff_u32 => {
+2841 let field = MyFieldU32(U32);
+2842 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2843 let out = field.diff(reversed);
+2844 assert_eq!("11110101000100111100100010101111", out.as_binary());
+2845 assert_eq!(4111714479, out.as_integer());
+2846 }
+2847 diff_u64 => {
+2848 let field = MyFieldU64(U64);
+2849 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2850 let out = field.diff(reversed);
+2851 assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", out.as_binary());
+2852 assert_eq!(1495798268358312744, out.as_integer());
+2853 }
+2854 diff_u128 => {
+2855 let field = MyFieldU128(U128);
+2856 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2857 let out = field.diff(reversed);
+2858 assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", out.as_binary());
+2859 assert_eq!(193799958082971305581995159990093034377, out.as_integer());
+2860 }
+2861 // diff_usize => {
+2862 // let field = MyFieldUsize(USIZE);
+2863 // }
+2864 }
+2865
+2866 // combine
+2867 tests! {
+2868 combine_u8 => {
+2869 let field = MyFieldU8(U8);
+2870 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2871 let out = field.combine(reversed);
+2872 assert_eq!("11111111", out.as_binary());
+2873 assert_eq!(255, out.as_integer());
+2874 }
+2875 combine_u16 => {
+2876 let field = MyFieldU16(U16);
+2877 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2878 let out = field.combine(reversed);
+2879 assert_eq!("1110101111010111", out.as_binary());
+2880 assert_eq!(60375, out.as_integer());
+2881 }
+2882 combine_u32 => {
+2883 let field = MyFieldU32(U32);
+2884 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2885 let out = field.combine(reversed);
+2886 assert_eq!("11111101100100111100100110111111", out.as_binary());
+2887 assert_eq!(4254321087, out.as_integer());
+2888 }
+2889 combine_u64 => {
+2890 let field = MyFieldU64(U64);
+2891 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2892 let out = field.combine(reversed);
+2893 assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", out.as_binary());
+2894 assert_eq!(18361808577405668223, out.as_integer());
+2895 }
+2896 combine_u128 => {
+2897 let field = MyFieldU128(U128);
+2898 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2899 let out = field.combine(reversed);
+2900 assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", out.as_binary());
+2901 assert_eq!(332296039312012448238196841470979719071, out.as_integer());
+2902 }
+2903 // combine_usize => {
+2904 // let field = MyFieldUsize(USIZE);
+2905 // }
+2906 }
+2907
+2908 // intersect
+2909 tests! {
+2910 intersect_u8 => {
+2911 let field = MyFieldU8(U8);
+2912 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2913 let out = field.intersect(reversed);
+2914 assert_eq!("01011010", out.as_binary());
+2915 assert_eq!(90, out.as_integer());
+2916 }
+2917 intersect_u16 => {
+2918 let field = MyFieldU16(U16);
+2919 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2920 let out = field.intersect(reversed);
+2921 assert_eq!("0100000000000010", out.as_binary());
+2922 assert_eq!(16386, out.as_integer());
+2923 }
+2924 intersect_u32 => {
+2925 let field = MyFieldU32(U32);
+2926 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2927 let out = field.intersect(reversed);
+2928 assert_eq!("00001000100000000000000100010000", out.as_binary());
+2929 assert_eq!(142606608, out.as_integer());
+2930 }
+2931 intersect_u64 => {
+2932 let field = MyFieldU64(U64);
+2933 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2934 let out = field.intersect(reversed);
+2935 assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", out.as_binary());
+2936 assert_eq!(16866010309047355479, out.as_integer());
+2937 }
+2938 intersect_u128 => {
+2939 let field = MyFieldU128(U128);
+2940 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2941 let out = field.intersect(reversed);
+2942 assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", out.as_binary());
+2943 assert_eq!(138496081229041142656201681480886684694, out.as_integer());
+2944 }
+2945 // intersect_usize => {
+2946 // let field = MyFieldUsize(USIZE);
+2947 // }
+2948 }
+2949
+2950 // into diff
+2951 tests! {
+2952 into_diff_u8 => {
+2953 let field = MyFieldU8(U8);
+2954 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2955 let out = field.into_diff(reversed);
+2956 assert_eq!("10100101", out.as_binary());
+2957 assert_eq!(165, out.as_integer());
+2958 }
+2959 into_diff_u16 => {
+2960 let field = MyFieldU16(U16);
+2961 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2962 let out = field.into_diff(reversed);
+2963 assert_eq!("1010101111010101", out.as_binary());
+2964 assert_eq!(43989, out.as_integer());
+2965 }
+2966 into_diff_u32 => {
+2967 let field = MyFieldU32(U32);
+2968 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2969 let out = field.into_diff(reversed);
+2970 assert_eq!("11110101000100111100100010101111", out.as_binary());
+2971 assert_eq!(4111714479, out.as_integer());
+2972 }
+2973 into_diff_u64 => {
+2974 let field = MyFieldU64(U64);
+2975 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2976 let out = field.into_diff(reversed);
+2977 assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", out.as_binary());
+2978 assert_eq!(1495798268358312744, out.as_integer());
+2979 }
+2980 into_diff_u128 => {
+2981 let field = MyFieldU128(U128);
+2982 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2983 let out = field.into_diff(reversed);
+2984 assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", out.as_binary());
+2985 assert_eq!(193799958082971305581995159990093034377, out.as_integer());
+2986 }
+2987 // into_diff_usize => {
+2988 // let field = MyFieldUsize(USIZE);
+2989 // }
+2990 }
+2991
+2992 // into combined
+2993 tests! {
+2994 into_combined_u8 => {
+2995 let field = MyFieldU8(U8);
+2996 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+2997 let out = field.into_combined(reversed);
+2998 assert_eq!("11111111", out.as_binary());
+2999 assert_eq!(255, out.as_integer());
+3000 }
+3001 into_combined_u16 => {
+3002 let field = MyFieldU16(U16);
+3003 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3004 let out = field.into_combined(reversed);
+3005 assert_eq!("1110101111010111", out.as_binary());
+3006 assert_eq!(60375, out.as_integer());
+3007 }
+3008 into_combined_u32 => {
+3009 let field = MyFieldU32(U32);
+3010 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3011 let out = field.into_combined(reversed);
+3012 assert_eq!("11111101100100111100100110111111", out.as_binary());
+3013 assert_eq!(4254321087, out.as_integer());
+3014 }
+3015 into_combined_u64 => {
+3016 let field = MyFieldU64(U64);
+3017 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3018 let out = field.into_combined(reversed);
+3019 assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", out.as_binary());
+3020 assert_eq!(18361808577405668223, out.as_integer());
+3021 }
+3022 into_combined_u128 => {
+3023 let field = MyFieldU128(U128);
+3024 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3025 let out = field.into_combined(reversed);
+3026 assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", out.as_binary());
+3027 assert_eq!(332296039312012448238196841470979719071, out.as_integer());
+3028 }
+3029 // into_combined_usize => {
+3030 // let field = MyFieldUsize(USIZE);
+3031 // }
+3032 }
+3033
+3034 // into intersection
+3035 tests! {
+3036 into_intersection_u8 => {
+3037 let field = MyFieldU8(U8);
+3038 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3039 let out = field.into_intersection(reversed);
+3040 assert_eq!("01011010", out.as_binary());
+3041 assert_eq!(90, out.as_integer());
+3042 }
+3043 into_intersection_u16 => {
+3044 let field = MyFieldU16(U16);
+3045 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3046 let out = field.into_intersection(reversed);
+3047 assert_eq!("0100000000000010", out.as_binary());
+3048 assert_eq!(16386, out.as_integer());
+3049 }
+3050 into_intersection_u32 => {
+3051 let field = MyFieldU32(U32);
+3052 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3053 let out = field.into_intersection(reversed);
+3054 assert_eq!("00001000100000000000000100010000", out.as_binary());
+3055 assert_eq!(142606608, out.as_integer());
+3056 }
+3057 into_intersection_u64 => {
+3058 let field = MyFieldU64(U64);
+3059 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3060 let out = field.into_intersection(reversed);
+3061 assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", out.as_binary());
+3062 assert_eq!(16866010309047355479, out.as_integer());
+3063 }
+3064 into_intersection_u128 => {
+3065 let field = MyFieldU128(U128);
+3066 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3067 let out = field.into_intersection(reversed);
+3068 assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", out.as_binary());
+3069 assert_eq!(138496081229041142656201681480886684694, out.as_integer());
+3070 }
+3071 // into_intersection_usize => {
+3072 // let field = MyFieldUsize(USIZE);
+3073 // }
+3074 }
+3075
+3076 // field from flag
+3077 tests! {
+3078 field_from_flag_u8 => {
+3079 for index in 0..u8::BITS {
+3080 let flag = MyFlagsU8::from(index as u8);
+3081 let field = MyFieldU8::from(flag);
+3082 assert_eq!(MyFieldU8(0u8 | (1 << index)), field)
+3083 }
+3084 }
+3085 field_from_flag_u16 => {
+3086 for index in 0..u16::BITS {
+3087 let flag = MyFlagsU16::from(index as u8);
+3088 let field = MyFieldU16::from(flag);
+3089 assert_eq!(MyFieldU16(0u16 | (1 << index)), field)
+3090 }
+3091 }
+3092 field_from_flag_u32 => {
+3093 for index in 0..u32::BITS {
+3094 let flag = MyFlagsU32::from(index as u8);
+3095 let field = MyFieldU32::from(flag);
+3096 assert_eq!(MyFieldU32(0u32 | (1 << index)), field)
+3097 }
+3098 }
+3099 field_from_flag_u64 => {
+3100 for index in 0..u64::BITS {
+3101 let flag = MyFlagsU64::from(index as u8);
+3102 let field = MyFieldU64::from(flag);
+3103 assert_eq!(MyFieldU64(0u64 | (1 << index)), field)
+3104 }
+3105 }
+3106 field_from_flag_u128 => {
+3107 for index in 0..u128::BITS {
+3108 let flag = MyFlagsU128::from(index as u8);
+3109 let field = MyFieldU128::from(flag);
+3110 assert_eq!(MyFieldU128(0u128 | (1 << index)), field)
+3111 }
+3112 }
+3113 field_from_flag_usize => {
+3114 for index in 0..usize::BITS {
+3115 let flag = MyFlagsUsize::from(index as u8);
+3116 let field = MyFieldUsize::from(flag);
+3117 assert_eq!(MyFieldUsize(0usize | (1 << index)), field)
+3118 }
+3119 }
+3120 }
+3121
+3122 // $name & $name
+3123 tests! {
+3124 bitwise_name_and_name_u8 => {
+3125 let field = MyFieldU8(U8);
+3126 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3127 let out = field & reversed;
+3128 assert_eq!("01011010", out.as_binary());
+3129 assert_eq!(90, out.as_integer());
+3130 }
+3131 bitwise_name_and_name_u16 => {
+3132 let field = MyFieldU16(U16);
+3133 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3134 let out = field & reversed;
+3135 assert_eq!("0100000000000010", out.as_binary());
+3136 assert_eq!(16386, out.as_integer());
+3137 }
+3138 bitwise_name_and_name_u32 => {
+3139 let field = MyFieldU32(U32);
+3140 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3141 let out = field & reversed;
+3142 assert_eq!("00001000100000000000000100010000", out.as_binary());
+3143 assert_eq!(142606608, out.as_integer());
+3144 }
+3145 bitwise_name_and_name_u64 => {
+3146 let field = MyFieldU64(U64);
+3147 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3148 let out = field & reversed;
+3149 assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", out.as_binary());
+3150 assert_eq!(16866010309047355479, out.as_integer());
+3151 }
+3152 bitwise_name_and_name_u128 => {
+3153 let field = MyFieldU128(U128);
+3154 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3155 let out = field & reversed;
+3156 assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", out.as_binary());
+3157 assert_eq!(138496081229041142656201681480886684694, out.as_integer());
+3158 }
+3159 // bitwise_name_and_name_usize => {
+3160 //
+3161 // }
+3162 }
+3163
+3164 // $name | $name
+3165 tests! {
+3166 bitwise_name_or_name_u8 => {
+3167 let field = MyFieldU8(U8);
+3168 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3169 let out = field | reversed;
+3170 assert_eq!("11111111", out.as_binary());
+3171 assert_eq!(255, out.as_integer());
+3172 }
+3173 bitwise_name_or_name_u16 => {
+3174 let field = MyFieldU16(U16);
+3175 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3176 let out = field | reversed;
+3177 assert_eq!("1110101111010111", out.as_binary());
+3178 assert_eq!(60375, out.as_integer());
+3179 }
+3180 bitwise_name_or_name_u32 => {
+3181 let field = MyFieldU32(U32);
+3182 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3183 let out = field | reversed;
+3184 assert_eq!("11111101100100111100100110111111", out.as_binary());
+3185 assert_eq!(4254321087, out.as_integer());
+3186 }
+3187 bitwise_name_or_name_u64 => {
+3188 let field = MyFieldU64(U64);
+3189 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3190 let out = field | reversed;
+3191 assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", out.as_binary());
+3192 assert_eq!(18361808577405668223, out.as_integer());
+3193 }
+3194 bitwise_name_or_name_u128 => {
+3195 let field = MyFieldU128(U128);
+3196 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3197 let out = field | reversed;
+3198 assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", out.as_binary());
+3199 assert_eq!(332296039312012448238196841470979719071, out.as_integer());
+3200 }
+3201 // bitwise_name_or_name_usize => {
+3202 //
+3203 // }
+3204 }
+3205
+3206 // $name ^ $name
+3207 tests! {
+3208 bitwise_name_xor_name_u8 => {
+3209 let field = MyFieldU8(U8);
+3210 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3211 let out = field ^ reversed;
+3212 assert_eq!("10100101", out.as_binary());
+3213 assert_eq!(165, out.as_integer());
+3214 }
+3215 bitwise_name_xor_name_u16 => {
+3216 let field = MyFieldU16(U16);
+3217 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3218 let out = field ^ reversed;
+3219 assert_eq!("1010101111010101", out.as_binary());
+3220 assert_eq!(43989, out.as_integer());
+3221 }
+3222 bitwise_name_xor_name_u32 => {
+3223 let field = MyFieldU32(U32);
+3224 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3225 let out = field ^ reversed;
+3226 assert_eq!("11110101000100111100100010101111", out.as_binary());
+3227 assert_eq!(4111714479, out.as_integer());
+3228 }
+3229 bitwise_name_xor_name_u64 => {
+3230 let field = MyFieldU64(U64);
+3231 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3232 let out = field ^ reversed;
+3233 assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", out.as_binary());
+3234 assert_eq!(1495798268358312744, out.as_integer());
+3235 }
+3236 bitwise_name_xor_name_u128 => {
+3237 let field = MyFieldU128(U128);
+3238 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3239 let out = field ^ reversed;
+3240 assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", out.as_binary());
+3241 assert_eq!(193799958082971305581995159990093034377, out.as_integer());
+3242 }
+3243 // bitwise_name_xor_name_usize => {
+3244 //
+3245 // }
+3246 }
+3247
+3248 // $name &= $name
+3249 tests! {
+3250 bitwise_name_and_assign_name_u8 => {
+3251 let mut field = MyFieldU8(U8);
+3252 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3253 field &= reversed;
+3254 assert_eq!("01011010", field.as_binary());
+3255 assert_eq!(90, field.as_integer());
+3256 }
+3257 bitwise_name_and_assign_name_u16 => {
+3258 let mut field = MyFieldU16(U16);
+3259 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3260 field &= reversed;
+3261 assert_eq!("0100000000000010", field.as_binary());
+3262 assert_eq!(16386, field.as_integer());
+3263 }
+3264 bitwise_name_and_assign_name_u32 => {
+3265 let mut field = MyFieldU32(U32);
+3266 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3267 field &= reversed;
+3268 assert_eq!("00001000100000000000000100010000", field.as_binary());
+3269 assert_eq!(142606608, field.as_integer());
+3270 }
+3271 bitwise_name_and_assign_name_u64 => {
+3272 let mut field = MyFieldU64(U64);
+3273 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3274 field &= reversed;
+3275 assert_eq!("1110101000010000000110110000010000100000110110000000100001010111", field.as_binary());
+3276 assert_eq!(16866010309047355479, field.as_integer());
+3277 }
+3278 bitwise_name_and_assign_name_u128 => {
+3279 let mut field = MyFieldU128(U128);
+3280 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3281 field &= reversed;
+3282 assert_eq!("01101000001100010110000000000000001000000110000000100001010111011011101010000100000001100000010000000000000001101000110000010110", field.as_binary());
+3283 assert_eq!(138496081229041142656201681480886684694, field.as_integer());
+3284 }
+3285 // bitwise_name_and_assign_name_usize => {
+3286 //
+3287 // }
+3288 }
+3289
+3290 // $name |= $name
+3291 tests! {
+3292 bitwise_name_or_assign_name_u8 => {
+3293 let mut field = MyFieldU8(U8);
+3294 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3295 field |= reversed;
+3296 assert_eq!("11111111", field.as_binary());
+3297 assert_eq!(255, field.as_integer());
+3298 }
+3299 bitwise_name_or_assign_name_u16 => {
+3300 let mut field = MyFieldU16(U16);
+3301 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3302 field |= reversed;
+3303 assert_eq!("1110101111010111", field.as_binary());
+3304 assert_eq!(60375, field.as_integer());
+3305 }
+3306 bitwise_name_or_assign_name_u32 => {
+3307 let mut field = MyFieldU32(U32);
+3308 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3309 field |= reversed;
+3310 assert_eq!("11111101100100111100100110111111", field.as_binary());
+3311 assert_eq!(4254321087, field.as_integer());
+3312 }
+3313 bitwise_name_or_assign_name_u64 => {
+3314 let mut field = MyFieldU64(U64);
+3315 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3316 field |= reversed;
+3317 assert_eq!("1111111011010010001111111001110110111001111111000100101101111111", field.as_binary());
+3318 assert_eq!(18361808577405668223, field.as_integer());
+3319 }
+3320 bitwise_name_or_assign_name_u128 => {
+3321 let mut field = MyFieldU128(U128);
+3322 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3323 field |= reversed;
+3324 assert_eq!("11111001111111011110001110100101111101111110111101101011111111111111111111010110111101111110111110100101110001111011111110011111", field.as_binary());
+3325 assert_eq!(332296039312012448238196841470979719071, field.as_integer());
+3326 }
+3327 // bitwise_name_or_assign_name_usize => {
+3328 //
+3329 // }
+3330 }
+3331
+3332 // $name ^= $name
+3333 tests! {
+3334 bitwise_name_xor_assign_name_u8 => {
+3335 let mut field = MyFieldU8(U8);
+3336 let reversed = MyFieldU8(u8::from_str_radix(B8.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3337 field ^= reversed;
+3338 assert_eq!("10100101", field.as_binary());
+3339 assert_eq!(165, field.as_integer());
+3340 }
+3341 bitwise_name_xor_assign_name_u16 => {
+3342 let mut field = MyFieldU16(U16);
+3343 let reversed = MyFieldU16(u16::from_str_radix(B16.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3344 field ^= reversed;
+3345 assert_eq!("1010101111010101", field.as_binary());
+3346 assert_eq!(43989, field.as_integer());
+3347 }
+3348 bitwise_name_xor_assign_name_u32 => {
+3349 let mut field = MyFieldU32(U32);
+3350 let reversed = MyFieldU32(u32::from_str_radix(B32.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3351 field ^= reversed;
+3352 assert_eq!("11110101000100111100100010101111", field.as_binary());
+3353 assert_eq!(4111714479, field.as_integer());
+3354 }
+3355 bitwise_name_xor_assign_name_u64 => {
+3356 let mut field = MyFieldU64(U64);
+3357 let reversed = MyFieldU64(u64::from_str_radix(B64.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3358 field ^= reversed;
+3359 assert_eq!("0001010011000010001001001001100110011001001001000100001100101000", field.as_binary());
+3360 assert_eq!(1495798268358312744, field.as_integer());
+3361 }
+3362 bitwise_name_xor_assign_name_u128 => {
+3363 let mut field = MyFieldU128(U128);
+3364 let reversed = MyFieldU128(u128::from_str_radix(B128.chars().rev().collect::<String>().as_str(), 2).unwrap());
+3365 field ^= reversed;
+3366 assert_eq!("10010001110011001000001110100101110101111000111101001010101000100100010101010010111100011110101110100101110000010011001110001001", field.as_binary());
+3367 assert_eq!(193799958082971305581995159990093034377, field.as_integer());
+3368 }
+3369 // bitwise_name_xor_assign_name_usize => {
+3370 //
+3371 // }
+3372 }
+3373
+3374 // $name & $flag
+3375 tests! {
+3376 bitwise_name_and_flag_u8 => {
+3377 for index in 0..u8::BITS {
+3378 let mask = MyFieldU8(u8::MAX) & MyFlagsU8::from(index as u8);
+3379 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3380 }
+3381 }
+3382 bitwise_name_and_flag_u16 => {
+3383 for index in 0..u16::BITS {
+3384 let mask = MyFieldU16(u16::MAX) & MyFlagsU16::from(index as u8);
+3385 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3386 }
+3387 }
+3388 bitwise_name_and_flag_u32 => {
+3389 for index in 0..u32::BITS {
+3390 let mask = MyFieldU32(u32::MAX) & MyFlagsU32::from(index as u8);
+3391 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3392 }
+3393 }
+3394 bitwise_name_and_flag_u64 => {
+3395 for index in 0..u64::BITS {
+3396 let mask = MyFieldU64(u64::MAX) & MyFlagsU64::from(index as u8);
+3397 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3398 }
+3399 }
+3400 bitwise_name_and_flag_u128 => {
+3401 for index in 0..u128::BITS {
+3402 let mask = MyFieldU128(u128::MAX) & MyFlagsU128::from(index as u8);
+3403 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3404 }
+3405 }
+3406 // bitwise_name_and_flag_usize => {
+3407 //
+3408 // }
+3409 }
+3410
+3411 // $name | $flag
+3412 tests! {
+3413 bitwise_name_or_flag_u8 => {
+3414 for index in 0..u8::BITS {
+3415 let mask = MyFieldU8(0) | MyFlagsU8::from(index as u8);
+3416 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3417 }
+3418 }
+3419 bitwise_name_or_flag_u16 => {
+3420 for index in 0..u16::BITS {
+3421 let mask = MyFieldU16(0) | MyFlagsU16::from(index as u8);
+3422 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3423 }
+3424 }
+3425 bitwise_name_or_flag_u32 => {
+3426 for index in 0..u32::BITS {
+3427 let mask = MyFieldU32(0) | MyFlagsU32::from(index as u8);
+3428 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3429 }
+3430 }
+3431 bitwise_name_or_flag_u64 => {
+3432 for index in 0..u64::BITS {
+3433 let mask = MyFieldU64(0) | MyFlagsU64::from(index as u8);
+3434 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3435 }
+3436 }
+3437 bitwise_name_or_flag_u128 => {
+3438 for index in 0..u128::BITS {
+3439 let mask = MyFieldU128(0) | MyFlagsU128::from(index as u8);
+3440 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3441 }
+3442 }
+3443 // bitwise_name_or_flag_usize => {
+3444 //
+3445 // }
+3446 }
+3447
+3448 // $name ^ $flag
+3449 tests! {
+3450 bitwise_name_xor_flag_u8 => {
+3451 for index in 0..u8::BITS {
+3452 let mask = MyFieldU8(0) ^ MyFlagsU8::from(index as u8);
+3453 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3454 }
+3455 }
+3456 bitwise_name_xor_flag_u16 => {
+3457 for index in 0..u16::BITS {
+3458 let mask = MyFieldU16(0) ^ MyFlagsU16::from(index as u8);
+3459 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3460 }
+3461 }
+3462 bitwise_name_xor_flag_u32 => {
+3463 for index in 0..u32::BITS {
+3464 let mask = MyFieldU32(0) ^ MyFlagsU32::from(index as u8);
+3465 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3466 }
+3467 }
+3468 bitwise_name_xor_flag_u64 => {
+3469 for index in 0..u64::BITS {
+3470 let mask = MyFieldU64(0) ^ MyFlagsU64::from(index as u8);
+3471 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3472 }
+3473 }
+3474 bitwise_name_xor_flag_u128 => {
+3475 for index in 0..u128::BITS {
+3476 let mask = MyFieldU128(0) ^ MyFlagsU128::from(index as u8);
+3477 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3478 }
+3479 }
+3480 // bitwise_name_xor_flag_usize => {
+3481 //
+3482 // }
+3483 }
+3484
+3485 // $name &= $flag
+3486 tests! {
+3487 bitwise_name_and_assign_flag_u8 => {
+3488 for index in 0..u8::BITS {
+3489 let mut mask = MyFieldU8(u8::MAX);
+3490 mask &= MyFlagsU8::from(index as u8);
+3491 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3492 }
+3493 }
+3494 bitwise_name_and_assign_flag_u16 => {
+3495 for index in 0..u16::BITS {
+3496 let mut mask = MyFieldU16(u16::MAX);
+3497 mask &= MyFlagsU16::from(index as u8);
+3498 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3499 }
+3500 }
+3501 bitwise_name_and_assign_flag_u32 => {
+3502 for index in 0..u32::BITS {
+3503 let mut mask = MyFieldU32(u32::MAX);
+3504 mask &= MyFlagsU32::from(index as u8);
+3505 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3506 }
+3507 }
+3508 bitwise_name_and_assign_flag_u64 => {
+3509 for index in 0..u64::BITS {
+3510 let mut mask = MyFieldU64(u64::MAX);
+3511 mask &= MyFlagsU64::from(index as u8);
+3512 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3513 }
+3514 }
+3515 bitwise_name_and_assign_flag_u128 => {
+3516 for index in 0..u128::BITS {
+3517 let mut mask = MyFieldU128(u128::MAX);
+3518 mask &= MyFlagsU128::from(index as u8);
+3519 assert_eq!(0 | !(1 << (index as u8) ), mask.as_integer());
+3520 }
+3521 }
+3522 // bitwise_name_and_assign_flag_usize => {
+3523 //
+3524 // }
+3525 }
+3526
+3527 // $name |= $flag
+3528 tests! {
+3529 bitwise_name_or_assign_flag_u8 => {
+3530 for index in 0..u8::BITS {
+3531 let mut mask = MyFieldU8(0);
+3532 mask |= MyFlagsU8::from(index as u8);
+3533 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3534 }
+3535 }
+3536 bitwise_name_or_assign_flag_u16 => {
+3537 for index in 0..u16::BITS {
+3538 let mut mask = MyFieldU16(0);
+3539 mask |= MyFlagsU16::from(index as u8);
+3540 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3541 }
+3542 }
+3543 bitwise_name_or_assign_flag_u32 => {
+3544 for index in 0..u32::BITS {
+3545 let mut mask = MyFieldU32(0);
+3546 mask |= MyFlagsU32::from(index as u8);
+3547 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3548 }
+3549 }
+3550 bitwise_name_or_assign_flag_u64 => {
+3551 for index in 0..u64::BITS {
+3552 let mut mask = MyFieldU64(0);
+3553 mask |= MyFlagsU64::from(index as u8);
+3554 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3555 }
+3556 }
+3557 bitwise_name_or_assign_flag_u128 => {
+3558 for index in 0..u128::BITS {
+3559 let mut mask = MyFieldU128(0);
+3560 mask |= MyFlagsU128::from(index as u8);
+3561 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3562 }
+3563 }
+3564 // bitwise_name_or_assign_flag_usize => {
+3565 //
+3566 // }
+3567 }
+3568
+3569 // $name ^= $flag
+3570 tests! {
+3571 bitwise_name_xor_assign_flag_u8 => {
+3572 for index in 0..u8::BITS {
+3573 let mut mask = MyFieldU8(0);
+3574 mask ^= MyFlagsU8::from(index as u8);
+3575 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3576 }
+3577 }
+3578 bitwise_name_xor_assign_flag_u16 => {
+3579 for index in 0..u16::BITS {
+3580 let mut mask = MyFieldU16(0);
+3581 mask ^= MyFlagsU16::from(index as u8);
+3582 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3583 }
+3584 }
+3585 bitwise_name_xor_assign_flag_u32 => {
+3586 for index in 0..u32::BITS {
+3587 let mut mask = MyFieldU32(0);
+3588 mask ^= MyFlagsU32::from(index as u8);
+3589 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3590 }
+3591 }
+3592 bitwise_name_xor_assign_flag_u64 => {
+3593 for index in 0..u64::BITS {
+3594 let mut mask = MyFieldU64(0);
+3595 mask ^= MyFlagsU64::from(index as u8);
+3596 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3597 }
+3598 }
+3599 bitwise_name_xor_assign_flag_u128 => {
+3600 for index in 0..u128::BITS {
+3601 let mut mask = MyFieldU128(0);
+3602 mask ^= MyFlagsU128::from(index as u8);
+3603 assert_eq!(0 | (1 << (index as u8) ), mask.as_integer());
+3604 }
+3605 }
+3606 // bitwise_name_xor_assign_flag_usize => {
+3607 //
+3608 // }
+3609 }
+3610
+3611 // $flag & $flag
+3612 tests! {
+3613 bitwise_flag_and_flag_u8 => {
+3614 for index_a in 0..u8::BITS {
+3615 let a = MyFlagsU8::from(index_a as u8);
+3616 for index_b in 0..u8::BITS {
+3617 let b = MyFlagsU8::from(index_b as u8);
+3618 assert_eq!(MyFieldU8(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
+3619 }
+3620 }
+3621 }
+3622 bitwise_flag_and_flag_u16 => {
+3623 for index_a in 0..u16::BITS {
+3624 let a = MyFlagsU16::from(index_a as u8);
+3625 for index_b in 0..u16::BITS {
+3626 let b = MyFlagsU16::from(index_b as u8);
+3627 assert_eq!(MyFieldU16(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
+3628 }
+3629 }
+3630 }
+3631 bitwise_flag_and_flag_u32 => {
+3632 for index_a in 0..u32::BITS {
+3633 let a = MyFlagsU32::from(index_a as u8);
+3634 for index_b in 0..u32::BITS {
+3635 let b = MyFlagsU32::from(index_b as u8);
+3636 assert_eq!(MyFieldU32(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
+3637 }
+3638 }
+3639 }
+3640 bitwise_flag_and_flag_u64 => {
+3641 for index_a in 0..u64::BITS {
+3642 let a = MyFlagsU64::from(index_a as u8);
+3643 for index_b in 0..u64::BITS {
+3644 let b = MyFlagsU64::from(index_b as u8);
+3645 assert_eq!(MyFieldU64(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
+3646 }
+3647 }
+3648 }
+3649 bitwise_flag_and_flag_u128 => {
+3650 for index_a in 0..u128::BITS {
+3651 let a = MyFlagsU128::from(index_a as u8);
+3652 for index_b in 0..u128::BITS {
+3653 let b = MyFlagsU128::from(index_b as u8);
+3654 assert_eq!(MyFieldU128(0 & 1 << index_a as u8 & 1 << index_b as u8), a & b);
+3655 }
+3656 }
+3657 }
+3658 // bitwise_flag_and_flag_usize => {
+3659 //
+3660 // }
+3661 }
+3662
+3663 // $flag | $flag
+3664 tests! {
+3665 bitwise_flag_or_flag_u8 => {
+3666 for index_a in 0..u8::BITS {
+3667 let a = MyFlagsU8::from(index_a as u8);
+3668 for index_b in 0..u8::BITS {
+3669 let b = MyFlagsU8::from(index_b as u8);
+3670 assert_eq!(MyFieldU8(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
+3671 }
+3672 }
+3673 }
+3674 bitwise_flag_or_flag_u16 => {
+3675 for index_a in 0..u16::BITS {
+3676 let a = MyFlagsU16::from(index_a as u8);
+3677 for index_b in 0..u16::BITS {
+3678 let b = MyFlagsU16::from(index_b as u8);
+3679 assert_eq!(MyFieldU16(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
+3680 }
+3681 }
+3682 }
+3683 bitwise_flag_or_flag_u32 => {
+3684 for index_a in 0..u32::BITS {
+3685 let a = MyFlagsU32::from(index_a as u8);
+3686 for index_b in 0..u32::BITS {
+3687 let b = MyFlagsU32::from(index_b as u8);
+3688 assert_eq!(MyFieldU32(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
+3689 }
+3690 }
+3691 }
+3692 bitwise_flag_or_flag_u64 => {
+3693 for index_a in 0..u64::BITS {
+3694 let a = MyFlagsU64::from(index_a as u8);
+3695 for index_b in 0..u64::BITS {
+3696 let b = MyFlagsU64::from(index_b as u8);
+3697 assert_eq!(MyFieldU64(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
+3698 }
+3699 }
+3700 }
+3701 bitwise_flag_or_flag_u128 => {
+3702 for index_a in 0..u128::BITS {
+3703 let a = MyFlagsU128::from(index_a as u8);
+3704 for index_b in 0..u128::BITS {
+3705 let b = MyFlagsU128::from(index_b as u8);
+3706 assert_eq!(MyFieldU128(0 | 1 << index_a as u8 | 1 << index_b as u8), a | b);
+3707 }
+3708 }
+3709 }
+3710 // bitwise_flag_or_flag_usize => {
+3711 //
+3712 // }
+3713 }
+3714
+3715 // $flag ^ $flag
+3716 tests! {
+3717 bitwise_flag_xor_flag_u8 => {
+3718 for index_a in 0..u8::BITS {
+3719 let a = MyFlagsU8::from(index_a as u8);
+3720 for index_b in 0..u8::BITS {
+3721 let b = MyFlagsU8::from(index_b as u8);
+3722 assert_eq!(MyFieldU8(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
+3723 }
+3724 }
+3725 }
+3726 bitwise_flag_xor_flag_u16 => {
+3727 for index_a in 0..u16::BITS {
+3728 let a = MyFlagsU16::from(index_a as u8);
+3729 for index_b in 0..u16::BITS {
+3730 let b = MyFlagsU16::from(index_b as u8);
+3731 assert_eq!(MyFieldU16(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
+3732 }
+3733 }
+3734 }
+3735 bitwise_flag_xor_flag_u32 => {
+3736 for index_a in 0..u32::BITS {
+3737 let a = MyFlagsU32::from(index_a as u8);
+3738 for index_b in 0..u32::BITS {
+3739 let b = MyFlagsU32::from(index_b as u8);
+3740 assert_eq!(MyFieldU32(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
+3741 }
+3742 }
+3743 }
+3744 bitwise_flag_xor_flag_u64 => {
+3745 for index_a in 0..u64::BITS {
+3746 let a = MyFlagsU64::from(index_a as u8);
+3747 for index_b in 0..u64::BITS {
+3748 let b = MyFlagsU64::from(index_b as u8);
+3749 assert_eq!(MyFieldU64(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
+3750 }
+3751 }
+3752 }
+3753 bitwise_flag_xor_flag_u128 => {
+3754 for index_a in 0..u128::BITS {
+3755 let a = MyFlagsU128::from(index_a as u8);
+3756 for index_b in 0..u128::BITS {
+3757 let b = MyFlagsU128::from(index_b as u8);
+3758 assert_eq!(MyFieldU128(0 ^ 1 << index_a as u8 ^ 1 << index_b as u8), a ^ b);
+3759 }
+3760 }
+3761 }
+3762 // bitwise_flag_xor_flag_usize => {
+3763 //
+3764 // }
+3765 }
+3766
+3767 // flag from u8
+3768 tests! {
+3769 flag_from_u8_u8 => {
+3770 for index in 0..u8::BITS {
+3771 let _ = MyFlagsU8::from(index as u8);
+3772 }
+3773 }
+3774 flag_from_u8_u16 => {
+3775 for index in 0..u16::BITS {
+3776 let _ = MyFlagsU16::from(index as u8);
+3777 }
+3778 }
+3779 flag_from_u8_u32 => {
+3780 for index in 0..u32::BITS {
+3781 let _ = MyFlagsU32::from(index as u8);
+3782 }
+3783 }
+3784 flag_from_u8_u64 => {
+3785 for index in 0..u64::BITS {
+3786 let _ = MyFlagsU64::from(index as u8);
+3787 }
+3788 }
+3789 flag_from_u8_u128 => {
+3790 for index in 0..u128::BITS {
+3791 let _ = MyFlagsU128::from(index as u8);
+3792 }
+3793 }
+3794 flag_from_u8_usize => {
+3795 for index in 0..usize::BITS {
+3796 let _ = MyFlagsUsize::from(index as u8);
+3797 }
+3798 }
+3799 }
+3800
+3801 // u8 from flag
+3802 tests! {
+3803 u8_from_flag_u8 => {
+3804 for index in 0..u8::BITS {
+3805 assert_eq!(MyFlagsU8::from(index as u8) as u8, index as u8)
+3806 }
+3807 }
+3808 u8_from_flag_u16 => {
+3809 for index in 0..u16::BITS {
+3810 assert_eq!(MyFlagsU16::from(index as u8) as u8, index as u8)
+3811 }
+3812 }
+3813 u8_from_flag_u32 => {
+3814 for index in 0..u32::BITS {
+3815 assert_eq!(MyFlagsU32::from(index as u8) as u8, index as u8)
+3816 }
+3817 }
+3818 u8_from_flag_u64 => {
+3819 for index in 0..u64::BITS {
+3820 assert_eq!(MyFlagsU64::from(index as u8) as u8, index as u8)
+3821 }
+3822 }
+3823 u8_from_flag_u128 => {
+3824 for index in 0..u128::BITS {
+3825 assert_eq!(MyFlagsU128::from(index as u8) as u8, index as u8)
+3826 }
+3827 }
+3828 u8_from_flag_usize => {
+3829 for index in 0..usize::BITS {
+3830 assert_eq!(MyFlagsUsize::from(index as u8) as u8, index as u8)
+3831 }
+3832 }
+3833 }
+3834}
+3835
+3836// -------------------------------------------------------------------------------------------------fn:) to \
+ restrict the search to a given item kind.","Accepted kinds are: fn, mod, struct, \
+ enum, trait, type, macro, \
+ and const.","Search functions by type signature (e.g., vec -> usize or \
+ -> vec or String, enum:Cow -> bool)","You can look for items with an exact name by putting double quotes around \
+ your request: \"string\"",`Look for functions that accept or return \
+ slices and \
+ arrays by writing square \
+ brackets (e.g., -> [u8] or [] -> Option)`,"Look for items inside another one by searching for a path: vec::Vec",].map(x=>""+x+"
").join("");const div_infos=document.createElement("div");addClass(div_infos,"infos");div_infos.innerHTML="${value.replaceAll(" ", " ")}`;}else{error[index]=value;}});const errorReport=document.createElement("h3");errorReport.className="error";errorReport.innerHTML=`Query parser error: "${error.join("")}".`;search.insertBefore(errorReport,search.firstElementChild);}else if(goToFirst||(count===1&&getSettingValue("go-to-only-result")==="true")){window.onunload=()=>{};window.searchState.removeQueryParameters();const a=output.querySelector("a");if(a){a.click();return;}}const fmtNbElems=count<10?`\u{2007}(${count})\u{2007}\u{2007}`:count<100?`\u{2007}(${count})\u{2007}`:`\u{2007}(${count})`;tabCount.innerHTML=fmtNbElems;tabCount.className="count";},isTypeSearch),];}async function showResults(docSearch,results,goToFirst,filterCrates){const search=window.searchState.outputElement();if(!search){return;}let crates="";const crateNames=await docSearch.getCrateNameList();if(crateNames.length>1){crates=" in Example of generated output, using only a bit field without a flag enum.
+Example of generated output, using only a bit field without a flag enum.
This module is only compiled with documentation builds and will not be available for import.
-use the bitfield macro to generate a field struct and flag enum.
Optional docstring for my example bit field.
-use the bitfield macro to generate a field struct and flag enum.
pub struct ExampleField(_);Optional docstring for my example bit field.
-Constant values describing ExampleField.
Number of bits in an instance of ExampleField.
Number of bytes used by an instance of ExampleField.
Maximum valid integer for ExampleField.
Constructors for creating instances of ExampleField.
Create a new instance of ExampleField from a u8 value.
Create a new instance of ExampleField from 0.
Create a new instance of ExampleField from the maximum possible integer value.
Create a new instance of ExampleField from a binary string.
Create a new instance of ExampleField from a binary string.
Current state of this bitfield.
-Field accessors by index for ExampleField.
Returns the value of the bit at the supplied index as a boolean.
-Sets the value of the bit at the supplied index to 0.
Flips the value of the bit at the supplied index.
-Combinators for ExampleField.
Returns a new ExampleFieldwith ones for flags that do not match. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Does not consume self.
Conversion methods.
-Returns a new ExampleFieldwith ones for flags that do not match. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Consumes self.
Performs the &= operation. Read more
Performs the |= operation. Read more
Performs the ^= operation. Read more
Returns a copy of the value. Read more
-Performs copy-assignment from source. Read more
Returns a field instance from value of its underlying type.
-Performs the conversion.
-This method tests for self and other values to be equal, and is used
-by ==. Read more
This method tests for !=.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
-operator. Read more
Mutably borrows from an owned value. Read more
-Calls U::from(self).
pub struct ExampleField(/* private fields */);Optional docstring for my example bit field.
+Constant values describing ExampleField.
Number of bits in an instance of ExampleField.
Number of bytes used by an instance of ExampleField.
Maximum valid integer for ExampleField.
Constructors for creating instances of ExampleField.
Create a new instance of ExampleField from a u8 value.
Create a new instance of ExampleField from 0.
Create a new instance of ExampleField from the maximum possible integer value.
Create a new instance of ExampleField from a binary string.
Create a new instance of ExampleField from a binary string.
Current state of this bitfield.
+Field accessors by index for ExampleField.
Returns the value of the bit at the supplied index as a boolean.
+Sets the value of the bit at the supplied index to 0.
Flips the value of the bit at the supplied index.
+Combinators for ExampleField.
Returns a new ExampleFieldwith ones for flags that do not match. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Does not consume self.
Conversion methods.
+Returns a new ExampleFieldwith ones for flags that do not match. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Consumes self.
&= operation. Read more|= operation. Read more^= operation. Read moresource. Read moreReturns a field instance from value of its underlying type.
+The resulting type after obtaining ownership.
-Creates owned data from borrowed data, usually by cloning. Read more
-toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
-From<T> for U chooses to do.
+#[repr(u8)]
-pub enum ExampleFlags {
- Flag0,
- Flag1,
- Flag2,
- Flag3,
- Flag4,
- Flag5,
- Flag6,
- Flag7,
-}Optional docstring for my flag enum.
-Flag0Optional docstring for Flag0
-Flag1Optional docstring for Flag1
-Flag2Optional docstring for Flag2
-Flag3Optional docstring for Flag3
-Flag4Optional docstring for Flag4
-Flag5Optional docstring for Flag5
-Flag6Optional docstring for Flag6
-Flag7Optional docstring for Flag7
-The resulting type after applying the & operator.
Performs the & operation. Read more
The resulting type after applying the & operator.
Performs the & operation. Read more
The resulting type after applying the & operator.
Performs the & operation. Read more
Performs the &= operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
Performs the |= operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
Performs the ^= operation. Read more
Returns a copy of the value. Read more
-Performs copy-assignment from source. Read more
Returns a flag as its corresponding u8 value.
Performs the conversion.
-Returns a field instance from a flag.
-Performs the conversion.
-Converts a u8 to a flag
Panics if the supplied u8 is out of range for fields base type.
-eg: for a 16-bit field (using u16),
+
#[repr(u8)]pub enum ExampleFlags {
+ Flag0 = 0,
+ Flag1 = 1,
+ Flag2 = 2,
+ Flag3 = 3,
+ Flag4 = 4,
+ Flag5 = 5,
+ Flag6 = 6,
+ Flag7 = 7,
+}Optional docstring for my flag enum.
+Optional docstring for Flag0
+Optional docstring for Flag1
+Optional docstring for Flag2
+Optional docstring for Flag3
+Optional docstring for Flag4
+Optional docstring for Flag5
+Optional docstring for Flag6
+Optional docstring for Flag7
+& operator.& operator.& operator.&= operation. Read more| operator.| operator.| operator.|= operation. Read more^ operator.^ operator.^ operator.^= operation. Read moresource. Read moreReturns a field instance from a flag.
+Returns a flag as its corresponding u8 value.
Converts a u8 to a flag
Panics if the supplied u8 is out of range for fields base type.
+eg: for a 16-bit field (using u16),
providing an index of 20 will cause a panic.
Performs the conversion.
-This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
-operator. Read more
Mutably borrows from an owned value. Read more
-Calls U::from(self).
The resulting type after obtaining ownership.
-Creates owned data from borrowed data, usually by cloning. Read more
-toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
-From<T> for U chooses to do.
+Example of generated output, using both a bit field and a flag enum.
+Example of generated output, using both a bit field and a flag enum.
This module is only compiled with documentation builds and will not be available for import.
-use the bitfield macro to generate a field struct and flag enum.
Optional docstring for my example bit field.
-Optional docstring for my flag enum.
-use the bitfield macro to generate a field struct and flag enum.
pub struct ExampleField(_);Optional docstring for my example bit field.
-Constant values describing ExampleField.
Number of bits in an instance of ExampleField.
Number of bytes used by an instance of ExampleField.
Maximum valid integer for ExampleField.
Constructors for creating instances of ExampleField.
Create a new instance of ExampleField from a u8 value.
Create a new instance of ExampleField from 0.
Create a new instance of ExampleField from the maximum possible integer value.
Create a new instance of ExampleField from a binary string.
Create a new instance of ExampleField from a binary string.
Current state of this bitfield.
-Field accessors by index for ExampleField.
Returns the value of the bit at the supplied index as a boolean.
-Sets the value of the bit at the supplied index to 0.
Flips the value of the bit at the supplied index.
-Named field accessors by ExampleFlags for ExampleField.
Returns the value of the bit at the supplied flag as a boolean.
-Sets the value of the bit at the supplied flag to 1.
Sets the value of the bit at the supplied flag to 0.
Flips the value of the bit at the supplied flag.
-Combinators for ExampleField.
Returns a new ExampleFieldwith ones for flags that do not match. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Does not consume self.
Conversion methods.
-Returns a new ExampleFieldwith ones for flags that do not match. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Consumes self.
The resulting type after applying the & operator.
Performs the & operation. Read more
The resulting type after applying the & operator.
Performs the & operation. Read more
The resulting type after applying the & operator.
Performs the & operation. Read more
Performs the &= operation. Read more
Performs the &= operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
Performs the |= operation. Read more
Performs the |= operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
Performs the ^= operation. Read more
Performs the ^= operation. Read more
Returns a copy of the value. Read more
-Performs copy-assignment from source. Read more
Returns a field instance from a flag.
-Performs the conversion.
-Returns a field instance from value of its underlying type.
-Performs the conversion.
-This method tests for self and other values to be equal, and is used
-by ==. Read more
This method tests for !=.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
-operator. Read more
Mutably borrows from an owned value. Read more
-Calls U::from(self).
pub struct ExampleField(/* private fields */);Optional docstring for my example bit field.
+Constant values describing ExampleField.
Number of bits in an instance of ExampleField.
Number of bytes used by an instance of ExampleField.
Maximum valid integer for ExampleField.
Constructors for creating instances of ExampleField.
Create a new instance of ExampleField from a u8 value.
Create a new instance of ExampleField from 0.
Create a new instance of ExampleField from the maximum possible integer value.
Create a new instance of ExampleField from a binary string.
Create a new instance of ExampleField from a binary string.
Current state of this bitfield.
+Field accessors by index for ExampleField.
Returns the value of the bit at the supplied index as a boolean.
+Sets the value of the bit at the supplied index to 0.
Flips the value of the bit at the supplied index.
+Named field accessors by ExampleFlags for ExampleField.
Returns the value of the bit at the supplied flag as a boolean.
+Sets the value of the bit at the supplied flag to 1.
Sets the value of the bit at the supplied flag to 0.
Flips the value of the bit at the supplied flag.
+Combinators for ExampleField.
Returns a new ExampleFieldwith ones for flags that do not match. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Does not consume self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Does not consume self.
Conversion methods.
+Returns a new ExampleFieldwith ones for flags that do not match. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on either input. Consumes self.
Returns a new ExampleFieldwith ones for flags that were set on both inputs. Consumes self.
& operator.& operator.& operator.&= operation. Read more&= operation. Read more| operator.| operator.| operator.|= operation. Read more|= operation. Read more^ operator.^ operator.^ operator.^= operation. Read more^= operation. Read moresource. Read moreReturns a field instance from a flag.
+Returns a field instance from value of its underlying type.
+The resulting type after obtaining ownership.
-Creates owned data from borrowed data, usually by cloning. Read more
-toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
-From<T> for U chooses to do.
+Examples of generated output using different configurations.
+Examples of generated output using different configurations.
This module is only compiled with documentation builds and will not be available for import.
-use the bitfield macro to generate a field struct and flag enum.
Example of generated output, using only a bit field without a flag enum.
-Example of generated output, using both a bit field and a flag enum.
-use the bitfield macro to generate a field struct and flag enum.
Supports field widths of 8, 16, 32, 64 and 128 bits.
bitfield - macro documentation.examples - examples of the output generated by the bitfield macro.bitfield - macro documentation.examples - examples of the output generated by the bitfield macro.Note: the example module is only complied with documentation builds and is not available for importing in the wild.
-Generate a bitfield struct with a flag enum… (The following examples all use this as a definition.)
-use ubits::bitfield;
+use ubits::bitfield;
bitfield! {
- pub u8 ExampleField
- ExampleFlags {
- 0 : Flag0,
- 1 : Flag1,
- 2 : Flag2,
- 3 : Flag3,
- 4 : Flag4,
- 5 : Flag5,
- 6 : Flag6,
- 7 : Flag7,
+ pub u8 ExampleField
+ ExampleFlags {
+ 0 : Flag0,
+ 1 : Flag1,
+ 2 : Flag2,
+ 3 : Flag3,
+ 4 : Flag4,
+ 5 : Flag5,
+ 6 : Flag6,
+ 7 : Flag7,
}
- }
-Instances
+ }From integer:
-let from_integer = ExampleField(123);
-assert_eq!(ExampleField(123), from_integer);From a binary string:
-let from_binary = ExampleField::from_binary_str("01111011");
-assert_eq!(ExampleField(123), from_binary)From ones:
-let from_ones = ExampleField::ones();
-assert_eq!("11111111", from_ones.as_binary());
-assert_eq!(255, from_ones.as_integer());From zeros:
-let from_zeros = ExampleField::zeros();
-assert_eq!("00000000", from_zeros.as_binary());
-assert_eq!(0, from_zeros.as_integer());Get bit value by field:
-let field = ExampleField::from_binary_str("01010101");
-assert!(field.get(ExampleFlags::Flag0));
-assert!(!field.get(ExampleFlags::Flag1));Get bit value by index:
-let field = ExampleField::from_binary_str("01010101");
-assert!(field.get_index(0));
-assert!(!field.get_index(1));Set bit value by field:
-let mut field = ExampleField::from_binary_str("01010101");
-field.set(ExampleFlags::Flag1);
-field.set(ExampleFlags::Flag3);
-assert_eq!("01011111", field.as_binary());Set bit value by index:
-let mut field = ExampleField::from_binary_str("01010101");
-field.set_index(1);
-field.set_index(3);
-assert_eq!("01011111", field.as_binary());Clear bit value by field:
-let mut field = ExampleField::from_binary_str("01010101");
-field.clear(ExampleFlags::Flag0);
-field.clear(ExampleFlags::Flag2);
-assert_eq!("01010000", field.as_binary());Clear bit value by index:
-let mut field = ExampleField::from_binary_str("01010101");
-field.clear_index(0);
-field.clear_index(2);
-assert_eq!("01010000", field.as_binary());Toggle bit value by field:
-let mut field = ExampleField::from_binary_str("01010101");
-field.toggle(ExampleFlags::Flag0);
-assert_eq!("01010100", field.as_binary());
-field.toggle(ExampleFlags::Flag0);
-assert_eq!("01010101", field.as_binary());Toggle bit value by index:
-let mut field = ExampleField::from_binary_str("01010101");
-field.toggle_index(0);
-assert_eq!("01010100", field.as_binary());
-field.toggle_index(0);
-assert_eq!("01010101", field.as_binary());Ubits can generate getter and setter methods for zero or more fields, if a name is provided.
-use ubits::bitfield;
+use ubits::bitfield;
bitfield! {
- pub u8 ExampleField
- ExampleFlags {
- 0 : Flag0 : (field_0), // is_field_0 & set_field_0 & clear_field_0 & toggle_field_0
- 1 : Flag1 : (field_1), // is_field_1 & set_field_1 & clear_field_1 & toggle_field_1
- 2 : Flag2,
- 3 : Flag3,
- 4 : Flag4,
- 5 : Flag5,
- 6 : Flag6,
- 7 : Flag7,
+ pub u8 ExampleField
+ ExampleFlags {
+ 0 : Flag0 : (field_0), // is_field_0 & set_field_0 & clear_field_0 & toggle_field_0
+ 1 : Flag1 : (field_1), // is_field_1 & set_field_1 & clear_field_1 & toggle_field_1
+ 2 : Flag2,
+ 3 : Flag3,
+ 4 : Flag4,
+ 5 : Flag5,
+ 6 : Flag6,
+ 7 : Flag7,
}
}
-let mut field = ExampleField::from_binary_str("01010101");
-assert_eq!(true, field.is_field_0());
-assert_eq!(false, field.is_field_1());
+let mut field = ExampleField::from_binary_str("01010101");
+assert_eq!(true, field.is_field_0());
+assert_eq!(false, field.is_field_1());
-field.set_field_1();
-assert_eq!(true, field.is_field_1());
+field.set_field_1();
+assert_eq!(true, field.is_field_1());
-field.clear_field_1();
-assert_eq!(false, field.is_field_1());
+field.clear_field_1();
+assert_eq!(false, field.is_field_1());
-field.toggle_field_1();
-assert_eq!(true, field.is_field_1());
-Combinations
+field.toggle_field_1();
+assert_eq!(true, field.is_field_1());Combine bit fields:
(use into_combined to consume self)
-let mut a = ExampleField::from_binary_str("01010101");
-let b = ExampleField::from_binary_str("10101010");
-assert_eq!("11111111", a.combine(b).as_binary());Get the intersection of two bitfields:
(use into_intersection to consume self)
-let mut a = ExampleField::from_binary_str("11000011");
-let b = ExampleField::from_binary_str("01111110");
-assert_eq!("01000010", a.intersect(b).as_binary());Get the diff of two bitfields:
(use into_diff to consume self)
-let mut a = ExampleField::from_binary_str("11000011");
-let b = ExampleField::from_binary_str("01100110");
-assert_eq!("10100101", a.diff(b).as_binary());Both bit field instances and flags use bitwise operators to change bit values.
-let mut from_zeros = ExampleField::zeros();
-assert_eq!("00000000", from_zeros.as_binary());
+let mut from_zeros = ExampleField::zeros();
+assert_eq!("00000000", from_zeros.as_binary());
-// set bit to 1
-from_zeros |= ExampleFlags::Flag1;
-assert_eq!("00000010", from_zeros.as_binary());
+// set bit to 1
+from_zeros |= ExampleFlags::Flag1;
+assert_eq!("00000010", from_zeros.as_binary());
-// set bit back to 0
-from_zeros &= ExampleFlags::Flag1;
-assert_eq!("00000000", from_zeros.as_binary());
+// set bit back to 0
+from_zeros &= ExampleFlags::Flag1;
+assert_eq!("00000000", from_zeros.as_binary());
-// toggle a bit
-from_zeros ^= ExampleFlags::Flag1;
-assert_eq!("00000010", from_zeros.as_binary());
+// toggle a bit
+from_zeros ^= ExampleFlags::Flag1;
+assert_eq!("00000010", from_zeros.as_binary());
-from_zeros ^= ExampleFlags::Flag1;
-assert_eq!("00000000", from_zeros.as_binary());Operations can also be chained together:
-let mut from_zeros = ExampleField::zeros() | ExampleFlags::Flag1 | ExampleFlags::Flag3;
-assert_eq!("00001010", from_zeros.as_binary());
+let mut from_zeros = ExampleField::zeros() | ExampleFlags::Flag1 | ExampleFlags::Flag3;
+assert_eq!("00001010", from_zeros.as_binary());
Bitfield instances can also be created from combining flags:
-let mut from_zeros = ExampleFlags::Flag1 | ExampleFlags::Flag3;
-assert_eq!("00001010", from_zeros.as_binary());
-The generated flags enum allows you to access bits by name.
-The flag has an associated u8 value,
+The flag has an associated u8 value,
which determines the index its target bit.
-(See bitfield for more info)
bitfield for more info)
With the following input…
1 0 1 0 0 1 1 0and the following flags…
@@ -244,9 +232,4 @@Examples of generated output using different configurations.
-Generates a bitfield struct and a corresponding flag enum.
-macro_rules! bitfield {
+bitfield in ubits - Rust bitfield
macro_rules! bitfield {
(
- $(#[$doc:meta])*
- $access:vis u8 $name:ident
+ $(#[$doc:meta])*
+ $access:vis u8 $name:ident
$(
- $(#[$flag_doc:meta])*
- $flag:ident {
+ $(#[$flag_doc:meta])*
+ $flag:ident {
$(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( : ( $named_getter:ident ) )?,
- )*
+ $(#[$member_doc:meta])*
+ $idx:literal : $field:ident $( : ( $named_getter:ident ) )?,
+ )*
}
- )?
+ )?
) => { ... };
(
- $(#[$doc:meta])*
- $access:vis u16 $name:ident
+ $(#[$doc:meta])*
+ $access:vis u16 $name:ident
$(
- $(#[$flag_doc:meta])*
- $flag:ident {
+ $(#[$flag_doc:meta])*
+ $flag:ident {
$(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
+ $(#[$member_doc:meta])*
+ $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+ )*
}
- )?
+ )?
) => { ... };
(
- $(#[$doc:meta])*
- $access:vis u32 $name:ident
+ $(#[$doc:meta])*
+ $access:vis u32 $name:ident
$(
- $(#[$flag_doc:meta])*
- $flag:ident {
+ $(#[$flag_doc:meta])*
+ $flag:ident {
$(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
+ $(#[$member_doc:meta])*
+ $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+ )*
}
- )?
+ )?
) => { ... };
(
- $(#[$doc:meta])*
- $access:vis u64 $name:ident
+ $(#[$doc:meta])*
+ $access:vis u64 $name:ident
$(
- $(#[$flag_doc:meta])*
- $flag:ident {
+ $(#[$flag_doc:meta])*
+ $flag:ident {
$(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
+ $(#[$member_doc:meta])*
+ $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+ )*
}
- )?
+ )?
) => { ... };
(
- $(#[$doc:meta])*
- $access:vis u128 $name:ident
+ $(#[$doc:meta])*
+ $access:vis u128 $name:ident
$(
- $(#[$flag_doc:meta])*
- $flag:ident {
+ $(#[$flag_doc:meta])*
+ $flag:ident {
$(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
+ $(#[$member_doc:meta])*
+ $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+ )*
}
- )?
+ )?
) => { ... };
(
- $(#[$doc:meta])*
- $access:vis usize $name:ident
+ $(#[$doc:meta])*
+ $access:vis usize $name:ident
$(
- $(#[$flag_doc:meta])*
- $flag:ident {
+ $(#[$flag_doc:meta])*
+ $flag:ident {
$(
- $(#[$member_doc:meta])*
- $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
- )*
+ $(#[$member_doc:meta])*
+ $idx:literal : $field:ident $( ( $named_getter:ident ) )?,
+ )*
}
- )?
+ )?
) => { ... };
-}
-Generates a bitfield struct and a corresponding flag enum.
+}Generates a bitfield struct and a corresponding flag enum.
Can be used multiple times in a single codebase as long as the identifiers are unique or are isolated so as not to clash.
-See the examples module for examples of the generated output.
See the examples module for examples of the generated output.
pub - optional accessor: if provided, both generated items will public.
@@ -105,11 +98,11 @@
u8 - unsigned integer type to use as a bit array. Must be an unsigned integer
-valid options are: u8,u16, u32, u64, u128, usize
u8,u16, u32, u64, u128, usize
0 : Flag0 - defines each member of the flag enum.
-The left hand side must be a u8 (0..=254)
+The left hand side must be a u8 (0..=254)
and must be less than the number of bits in the underlying unsigned type.
This value determines the index of the target bit within the field.
The right hand side can be any valid identifier (unique to this enum).
@@ -118,87 +111,86 @@
/// docstrings - Each element can take optional docstrings.
This includes the bit field struct, the flag enum, and each member within the flag enum.
-See examples for more information.
examples for more information.
Full Example - (see below for explanation for each parameter):
-use ubits::bitfield;
+use ubits::bitfield;
bitfield! {
- /// Optional docstring
- /// for [`ExampleField`] struct
- pub u8 ExampleField
- /// Optional docstring
- /// for [`ExampleFlags`] enum
- ExampleFlags {
- /// Optional docstring for [`ExampleFlags::Flag0`]
- 0 : Flag0,
- /// Optional docstring for [`ExampleFlags::Flag1`]
- 1 : Flag1,
- /// Optional docstring for [`ExampleFlags::Flag2`]
- 2 : Flag2,
- /// Optional docstring for [`ExampleFlags::Flag3`]
- 3 : Flag3,
- /// Optional docstring for [`ExampleFlags::Flag4`]
- 4 : Flag4,
- /// Optional docstring for [`ExampleFlags::Flag5`]
- 5 : Flag5,
- /// Optional docstring for [`ExampleFlags::Flag6`]
- 6 : Flag6,
- /// Optional docstring for [`ExampleFlags::Flag7`]
- 7 : Flag7,
+ /// Optional docstring
+ /// for [`ExampleField`] struct
+ pub u8 ExampleField
+ /// Optional docstring
+ /// for [`ExampleFlags`] enum
+ ExampleFlags {
+ /// Optional docstring for [`ExampleFlags::Flag0`]
+ 0 : Flag0,
+ /// Optional docstring for [`ExampleFlags::Flag1`]
+ 1 : Flag1,
+ /// Optional docstring for [`ExampleFlags::Flag2`]
+ 2 : Flag2,
+ /// Optional docstring for [`ExampleFlags::Flag3`]
+ 3 : Flag3,
+ /// Optional docstring for [`ExampleFlags::Flag4`]
+ 4 : Flag4,
+ /// Optional docstring for [`ExampleFlags::Flag5`]
+ 5 : Flag5,
+ /// Optional docstring for [`ExampleFlags::Flag6`]
+ 6 : Flag6,
+ /// Optional docstring for [`ExampleFlags::Flag7`]
+ 7 : Flag7,
}
}
You don’t have to name all the fields if you don’t need them…
You can use just a few from the front:
-use ubits::bitfield;
+use ubits::bitfield;
bitfield! {
- /// Optional docstring
- /// for [`ExampleField`] struct
- pub u8 ExampleField
- /// Optional docstring
- /// for [`ExampleFlags`] enum
- ExampleFlags {
- /// Optional docstring for [`ExampleFlags::Flag0`]
- 0 : Flag0,
- /// Optional docstring for [`ExampleFlags::Flag1`]
- 1 : Flag1,
- /// Optional docstring for [`ExampleFlags::Flag2`]
- 2 : Flag2,
+ /// Optional docstring
+ /// for [`ExampleField`] struct
+ pub u8 ExampleField
+ /// Optional docstring
+ /// for [`ExampleFlags`] enum
+ ExampleFlags {
+ /// Optional docstring for [`ExampleFlags::Flag0`]
+ 0 : Flag0,
+ /// Optional docstring for [`ExampleFlags::Flag1`]
+ 1 : Flag1,
+ /// Optional docstring for [`ExampleFlags::Flag2`]
+ 2 : Flag2,
}
}
… or any valid indices:
-use ubits::bitfield;
+use ubits::bitfield;
bitfield! {
- /// Optional docstring
- /// for [`ExampleField`] struct
- pub u8 ExampleField
- /// Optional docstring
- /// for [`ExampleFlags`] enum
- ExampleFlags {
- /// Optional docstring for [`ExampleFlags::Flag0`]
- 0 : Flag0,
- /// Optional docstring for [`ExampleFlags::Flag1`]
- 3 : Flag1,
- /// Optional docstring for [`ExampleFlags::Flag2`]
- 6 : Flag2,
+ /// Optional docstring
+ /// for [`ExampleField`] struct
+ pub u8 ExampleField
+ /// Optional docstring
+ /// for [`ExampleFlags`] enum
+ ExampleFlags {
+ /// Optional docstring for [`ExampleFlags::Flag0`]
+ 0 : Flag0,
+ /// Optional docstring for [`ExampleFlags::Flag1`]
+ 3 : Flag1,
+ /// Optional docstring for [`ExampleFlags::Flag2`]
+ 6 : Flag2,
}
}
… or just omit the flags altogether and use indices only.:
-use ubits::bitfield;
+use ubits::bitfield;
bitfield! {
- /// Optional docstring
- /// for [`ExampleField`] struct
- pub u8 ExampleField
+ /// Optional docstring
+ /// for [`ExampleField`] struct
+ pub u8 ExampleField
}
Note: if you omit flags, no flag enum will be generated
and no methods for the bitfield struct that rely on flags will be generated.
-
-
\ No newline at end of file
+