├── .github └── workflows │ └── rust.yml ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── MAINTENANCE.md ├── README.md └── src ├── conversion.rs └── lib.rs /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | format_check: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Format 19 | run: cargo fmt -- --check 20 | 21 | build_std: 22 | runs-on: ubuntu-latest 23 | 24 | steps: 25 | - uses: actions/checkout@v2 26 | - name: Build 27 | run: cargo build --verbose --no-default-features 28 | - name: Run tests 29 | run: cargo test --verbose --no-default-features 30 | 31 | build_no_std: 32 | runs-on: ubuntu-latest 33 | 34 | steps: 35 | - uses: actions/checkout@v2 36 | - name: Build 37 | run: cargo build --verbose --features std 38 | - name: Run tests 39 | run: cargo test --verbose --features std 40 | 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # These are backup files generated by rustfmt 6 | **/*.rs.bk 7 | 8 | # Cargo lock should not be included since this is a library 9 | Cargo.lock 10 | 11 | # Backup files for emacs 12 | **/*~ 13 | 14 | # Idea (Intelij) project file 15 | .idea 16 | *.iml 17 | 18 | # scripts in parent folder 19 | *.sh 20 | 21 | # gdb files 22 | **/*.gdb* -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). 6 | 7 | ## [Unreleased] 8 | ### Added 9 | ### Changed 10 | ### Deprecated 11 | ### Removed 12 | ### Fixed 13 | ### Security 14 | 15 | ## [0.1.6] - 2024-04-03 16 | ### Added 17 | - Support conversions for u1 18 | - Implement std::error::Error for TryFromIntError 19 | - Add BITS associated constant 20 | ### Changed 21 | - Mask values on write instead of read 22 | 23 | ## [0.1.3] - 2018-10-29 24 | ### Added 25 | - Added `i1` and `u1` types. 26 | - Added `i65`-`i127` and `u65`-`u127` types. 27 | 28 | 29 | ## [0.1.2] - 2018-05-18 30 | ### Added 31 | - Implemented `BitXor` and `BitXorAssign` for all types 32 | 33 | 34 | ## [0.1.1] - 2018-05-01 35 | ### Added 36 | - Implemented `BitAnd` and `BitAndAssign` for all types 37 | ### Changed 38 | ### Deprecated 39 | ### Removed 40 | ### Fixed 41 | ### Security 42 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ux" 3 | version = "0.1.6" 4 | authors = ["Kjetil Kjeka "] 5 | edition = "2021" 6 | 7 | description = "Implement the following non standard integers: u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63" 8 | 9 | license = "Apache-2.0/MIT" 10 | readme = "README.md" 11 | repository = "https://github.com/kjetilkjeka/uX.git" 12 | 13 | 14 | keywords = ["integer", "unaligned", "misaligned"] 15 | categories = ["embedded", "no-std", "data-structures"] 16 | 17 | 18 | [dependencies] 19 | 20 | [features] 21 | default = [] 22 | # The std feature only toggles whether the Error trait is implemented for error 23 | # types. Apart from that, this crate works without explicit indication both on 24 | # std and no_std systems. 25 | std = [] 26 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Kjetil Kjeka 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /MAINTENANCE.md: -------------------------------------------------------------------------------- 1 | # uX maintainence manual 2 | 3 | The project maintainers are the users designated as owners of the project's GitHub organization. 4 | 5 | We use pull requests to review changes to the master branch. 6 | Generally, before merging, pull requests should be reviewed by a maintainer 7 | who is not also the author of the PR. 8 | 9 | ## Development goals 10 | 11 | * Basic properties of the types in uX are advertised already in the README: 12 | Behave as close as possible to the corresponding builtin type, 13 | be stored like them, 14 | and give the compiler as much information as practical to work with them 15 | (eg. advertising niches). 16 | * Builtin types often have traits implemented for them in third party crates. 17 | We encourage these third parties to optionally depend on uX 18 | and implement the traits for these types as well; 19 | when that is impossible for some reason, 20 | we may add an optional dependency and implement the traits here instead. 21 | * On the long run, 22 | this crate's goal is to be obsoleted by ranged integers in the core library. 23 | When that happens 24 | (and there is at least [an issue](https://github.com/rust-lang/rfcs/issues/671) open), 25 | this crate can be demoted to a compatibility wrapper. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uX [![Crates.io](https://img.shields.io/crates/v/ux.svg)](https://crates.io/crates/ux) ![maintenance-status](https://img.shields.io/badge/maintenance-looking--for--maintainer-orange.svg) 2 | 3 | > Non standard integer types like `u7`, `u9`, `u10`, `u63`, `i7`, `i9` etc 4 | 5 | When non-standard-width integers are required in an application, the norm is to use a larger container and make sure the value is within range after manipulation. uX aims to take care of this once and for all by: 6 | - Providing `u1`-`u127` and `i1`-`i127` types that should behave as similar as possible to the built in rust types 7 | - The methods of the defined types are the same as for the built in types (far from all methods are implemented at this point, but fill out an issue or create a PR if something essential for you is missing) 8 | - Overflow will panic in debug and wrap in release. 9 | - All lossless infallible conversions are possible by using `From`. 10 | - All lossless fallible conversions are possible by using `TryFrom`. 11 | 12 | The uX types take up as much space as the smallest integer type that can contain them. 13 | # License 14 | 15 | Licensed under either of 16 | 17 | - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or 18 | http://www.apache.org/licenses/LICENSE-2.0) 19 | 20 | - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 21 | 22 | at your option. 23 | 24 | ## Contribution 25 | 26 | Unless you explicitly state otherwise, any contribution intentionally submitted 27 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 28 | dual licensed as above, without any additional terms or conditions. 29 | -------------------------------------------------------------------------------- /src/conversion.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | /// The error type returned when a checked integral type conversion fails. 4 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] 5 | pub struct TryFromIntError(pub(crate) ()); 6 | 7 | impl From for TryFromIntError { 8 | fn from(_: lib::core::num::TryFromIntError) -> TryFromIntError { 9 | TryFromIntError(()) 10 | } 11 | } 12 | 13 | impl From for TryFromIntError { 14 | fn from(_: lib::core::convert::Infallible) -> TryFromIntError { 15 | TryFromIntError(()) 16 | } 17 | } 18 | 19 | impl Display for TryFromIntError { 20 | fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { 21 | write!(f, "out of range integral type conversion attempted") 22 | } 23 | } 24 | 25 | #[cfg(feature = "std")] 26 | impl std::error::Error for TryFromIntError {} 27 | 28 | // Only implement if $from can be converted into $name lossless 29 | macro_rules! implement_from { 30 | {[$($name:ident),*], [$($from:ident),*] } => {$(implement_from!($name, $from);)*}; 31 | {$name:ident, [$($from:ident),*] } => {$(implement_from!($name, $from);)*}; 32 | {[$($name:ident),*], $from:ident } => {$(implement_from!($name, $from);)*}; 33 | {$name:ident, $from:ty} => { 34 | impl From<$from> for $name { 35 | fn from(x: $from) -> $name { 36 | $name(x.into()) 37 | } 38 | } 39 | }; 40 | } 41 | 42 | macro_rules! implement_try_from { 43 | {[$($name:ident),*], [$($from:ident),*] } => {$(implement_try_from!($name, $from);)*}; 44 | {$name:ident, [$($from:ident),*] } => {$(implement_try_from!($name, $from);)*}; 45 | {[$($name:ident),*], $from:ident } => {$(implement_try_from!($name, $from);)*}; 46 | {$name:ident, $from:ty} => { 47 | impl TryFrom<$from> for $name { 48 | type Error = TryFromIntError; 49 | 50 | fn try_from(x: $from) -> Result<$name, Self::Error> { 51 | // First get the value into the correct type 52 | let value = x.try_into()?; 53 | 54 | if value <= $name::MAX.into() && value >= $name::MIN.into() { 55 | Ok($name(value)) 56 | } else { 57 | Err(TryFromIntError(())) 58 | } 59 | } 60 | } 61 | }; 62 | } 63 | 64 | // Only implement if $type can be converted from $name lossless 65 | macro_rules! implement_into { 66 | {[$($name:ident),*], $from:ident } => {$(implement_into!($name, $from);)*}; 67 | {$name:ident, $into:ident} => { 68 | impl From<$name> for $into { 69 | fn from(x: $name) -> $into { 70 | $into::from(x.0) 71 | } 72 | } 73 | }; 74 | } 75 | 76 | macro_rules! implement_try_into { 77 | {[$($name:ident),*], $from:ident } => {$(implement_try_into!($name, $from);)*}; 78 | {$name:ident, $into:ident} => { 79 | 80 | impl TryFrom<$name> for $into { 81 | type Error = TryFromIntError; 82 | 83 | fn try_from(x: $name) -> Result<$into, Self::Error> { 84 | Ok($into::try_from(x.0)?) 85 | } 86 | } 87 | }; 88 | } 89 | 90 | // Implement From for all unsigned integers 91 | 92 | implement_try_from!([u1, u2, u3, u4, u5, u6, u7], u8); 93 | implement_from!([u9, u10, u11, u12, u13, u14, u15], u8); 94 | implement_from!([u17, u18, u19, u20, u21, u22, u23, u24], u8); 95 | implement_from!([u25, u26, u27, u28, u29, u30, u31], u8); 96 | implement_from!([u33, u34, u35, u36, u37, u38, u39, u40], u8); 97 | implement_from!([u41, u42, u43, u44, u45, u46, u47, u48], u8); 98 | implement_from!([u49, u50, u51, u52, u53, u54, u55, u56], u8); 99 | implement_from!([u57, u58, u59, u60, u61, u62, u63], u8); 100 | 101 | implement_into!([u1, u2, u3, u4, u5, u6, u7], u8); 102 | implement_try_into!([u9, u10, u11, u12, u13, u14, u15], u8); 103 | implement_try_into!([u17, u18, u19, u20, u21, u22, u23, u24], u8); 104 | implement_try_into!([u25, u26, u27, u28, u29, u30, u31], u8); 105 | implement_try_into!([u33, u34, u35, u36, u37, u38, u39, u40], u8); 106 | implement_try_into!([u41, u42, u43, u44, u45, u46, u47, u48], u8); 107 | implement_try_into!([u49, u50, u51, u52, u53, u54, u55, u56], u8); 108 | implement_try_into!([u57, u58, u59, u60, u61, u62, u63], u8); 109 | 110 | implement_try_from!([u1, u2, u3, u4, u5, u6, u7], u16); 111 | implement_try_from!([u9, u10, u11, u12, u13, u14, u15], u16); 112 | implement_from!([u17, u18, u19, u20, u21, u22, u23, u24], u16); 113 | implement_from!([u25, u26, u27, u28, u29, u30, u31], u16); 114 | implement_from!([u33, u34, u35, u36, u37, u38, u39, u40], u16); 115 | implement_from!([u41, u42, u43, u44, u45, u46, u47, u48], u16); 116 | implement_from!([u49, u50, u51, u52, u53, u54, u55, u56], u16); 117 | implement_from!([u57, u58, u59, u60, u61, u62, u63], u16); 118 | 119 | implement_into!([u1, u2, u3, u4, u5, u6, u7], u16); 120 | implement_into!([u9, u10, u11, u12, u13, u14, u15], u16); 121 | implement_try_into!([u17, u18, u19, u20, u21, u22, u23, u24], u16); 122 | implement_try_into!([u25, u26, u27, u28, u29, u30, u31], u16); 123 | implement_try_into!([u33, u34, u35, u36, u37, u38, u39, u40], u16); 124 | implement_try_into!([u41, u42, u43, u44, u45, u46, u47, u48], u16); 125 | implement_try_into!([u49, u50, u51, u52, u53, u54, u55, u56], u16); 126 | implement_try_into!([u57, u58, u59, u60, u61, u62, u63], u16); 127 | 128 | implement_try_from!([u1, u2, u3, u4, u5, u6, u7], u32); 129 | implement_try_from!([u9, u10, u11, u12, u13, u14, u15], u32); 130 | implement_try_from!([u17, u18, u19, u20, u21, u22, u23, u24], u32); 131 | implement_try_from!([u25, u26, u27, u28, u29, u30, u31], u32); 132 | implement_from!([u33, u34, u35, u36, u37, u38, u39, u40], u32); 133 | implement_from!([u41, u42, u43, u44, u45, u46, u47, u48], u32); 134 | implement_from!([u49, u50, u51, u52, u53, u54, u55, u56], u32); 135 | implement_from!([u57, u58, u59, u60, u61, u62, u63], u32); 136 | 137 | implement_into!([u1, u2, u3, u4, u5, u6, u7], u32); 138 | implement_into!([u9, u10, u11, u12, u13, u14, u15], u32); 139 | implement_into!([u17, u18, u19, u20, u21, u22, u23, u24], u32); 140 | implement_into!([u25, u26, u27, u28, u29, u30, u31], u32); 141 | implement_try_into!([u33, u34, u35, u36, u37, u38, u39, u40], u32); 142 | implement_try_into!([u41, u42, u43, u44, u45, u46, u47, u48], u32); 143 | implement_try_into!([u49, u50, u51, u52, u53, u54, u55, u56], u32); 144 | implement_try_into!([u57, u58, u59, u60, u61, u62, u63], u32); 145 | 146 | implement_try_from!([u1, u2, u3, u4, u5, u6, u7], u64); 147 | implement_try_from!([u9, u10, u11, u12, u13, u14, u15], u64); 148 | implement_try_from!([u17, u18, u19, u20, u21, u22, u23, u24], u64); 149 | implement_try_from!([u25, u26, u27, u28, u29, u30, u31], u64); 150 | implement_try_from!([u33, u34, u35, u36, u37, u38, u39, u40], u64); 151 | implement_try_from!([u41, u42, u43, u44, u45, u46, u47, u48], u64); 152 | implement_try_from!([u49, u50, u51, u52, u53, u54, u55, u56], u64); 153 | implement_try_from!([u57, u58, u59, u60, u61, u62, u63], u64); 154 | 155 | implement_into!([u1, u2, u3, u4, u5, u6, u7], u64); 156 | implement_into!([u9, u10, u11, u12, u13, u14, u15], u64); 157 | implement_into!([u17, u18, u19, u20, u21, u22, u23, u24], u64); 158 | implement_into!([u25, u26, u27, u28, u29, u30, u31], u64); 159 | implement_into!([u33, u34, u35, u36, u37, u38, u39, u40], u64); 160 | implement_into!([u41, u42, u43, u44, u45, u46, u47, u48], u64); 161 | implement_into!([u49, u50, u51, u52, u53, u54, u55, u56], u64); 162 | implement_into!([u57, u58, u59, u60, u61, u62, u63], u64); 163 | 164 | implement_try_into!([u1, u2, u3, u4, u5, u6, u7], usize); 165 | implement_try_into!([u9, u10, u11, u12, u13, u14, u15], usize); 166 | implement_try_into!([u17, u18, u19, u20, u21, u22, u23, u24], usize); 167 | implement_try_into!([u25, u26, u27, u28, u29, u30, u31], usize); 168 | implement_try_into!([u33, u34, u35, u36, u37, u38, u39, u40], usize); 169 | implement_try_into!([u41, u42, u43, u44, u45, u46, u47, u48], usize); 170 | implement_try_into!([u49, u50, u51, u52, u53, u54, u55, u56], usize); 171 | implement_try_into!([u57, u58, u59, u60, u61, u62, u63], usize); 172 | 173 | implement_try_from!( 174 | u1, 175 | [ 176 | u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 177 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 178 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, 179 | u60, u61, u62, u63, usize 180 | ] 181 | ); 182 | 183 | implement_from!(u2, [u1]); 184 | implement_try_from!( 185 | u2, 186 | [ 187 | u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, 188 | u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, 189 | u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, 190 | u61, u62, u63, usize 191 | ] 192 | ); 193 | 194 | implement_from!(u3, [u2, u1]); 195 | implement_try_from!( 196 | u3, 197 | [ 198 | u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, 199 | u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, 200 | u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, 201 | u62, u63, usize 202 | ] 203 | ); 204 | 205 | implement_from!(u4, [u1, u2, u3]); 206 | implement_try_from!( 207 | u4, 208 | [ 209 | u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, 210 | u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, 211 | u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, 212 | u63, usize 213 | ] 214 | ); 215 | 216 | implement_from!(u5, [u1, u2, u3, u4]); 217 | implement_try_from!( 218 | u5, 219 | [ 220 | u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, 221 | u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, 222 | u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, 223 | usize 224 | ] 225 | ); 226 | 227 | implement_from!(u6, [u1, u2, u3, u4, u5]); 228 | implement_try_from!( 229 | u6, 230 | [ 231 | u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, 232 | u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, 233 | u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, 234 | usize 235 | ] 236 | ); 237 | 238 | implement_from!(u7, [u1, u2, u3, u4, u5, u6]); 239 | implement_try_from!( 240 | u7, 241 | [ 242 | u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, 243 | u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, 244 | u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 245 | ] 246 | ); 247 | 248 | implement_from!(u9, [u1, u2, u3, u4, u5, u6, u7]); 249 | implement_try_from!( 250 | u9, 251 | [ 252 | u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, 253 | u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, 254 | u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 255 | ] 256 | ); 257 | 258 | implement_from!(u10, [u1, u2, u3, u4, u5, u6, u7, u9]); 259 | implement_try_from!( 260 | u10, 261 | [ 262 | u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, 263 | u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, 264 | u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 265 | ] 266 | ); 267 | 268 | implement_from!(u11, [u1, u2, u3, u4, u5, u6, u7, u9, u10]); 269 | implement_try_from!( 270 | u11, 271 | [ 272 | u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, 273 | u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, 274 | u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 275 | ] 276 | ); 277 | 278 | implement_from!(u12, [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11]); 279 | implement_try_from!( 280 | u12, 281 | [ 282 | u13, u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, 283 | u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, 284 | u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 285 | ] 286 | ); 287 | 288 | implement_from!(u13, [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12]); 289 | implement_try_from!( 290 | u13, 291 | [ 292 | u14, u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, 293 | u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, 294 | u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 295 | ] 296 | ); 297 | 298 | implement_from!(u14, [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13]); 299 | implement_try_from!( 300 | u14, 301 | [ 302 | u15, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, 303 | u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, 304 | u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 305 | ] 306 | ); 307 | 308 | implement_from!( 309 | u15, 310 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14] 311 | ); 312 | implement_try_from!( 313 | u15, 314 | [ 315 | u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, 316 | u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, 317 | u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 318 | ] 319 | ); 320 | 321 | implement_from!( 322 | u17, 323 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15] 324 | ); 325 | implement_try_from!( 326 | u17, 327 | [ 328 | u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, 329 | u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, 330 | u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 331 | ] 332 | ); 333 | 334 | implement_from!( 335 | u18, 336 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17] 337 | ); 338 | implement_try_from!( 339 | u18, 340 | [ 341 | u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, 342 | u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, 343 | u56, u57, u58, u59, u60, u61, u62, u63, usize 344 | ] 345 | ); 346 | 347 | implement_from!( 348 | u19, 349 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18] 350 | ); 351 | implement_try_from!( 352 | u19, 353 | [ 354 | u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, 355 | u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, 356 | u57, u58, u59, u60, u61, u62, u63, usize 357 | ] 358 | ); 359 | 360 | implement_from!( 361 | u20, 362 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19] 363 | ); 364 | implement_try_from!( 365 | u20, 366 | [ 367 | u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, 368 | u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, 369 | u58, u59, u60, u61, u62, u63, usize 370 | ] 371 | ); 372 | 373 | implement_from!( 374 | u21, 375 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20] 376 | ); 377 | implement_try_from!( 378 | u21, 379 | [ 380 | u22, u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, 381 | u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, 382 | u59, u60, u61, u62, u63, usize 383 | ] 384 | ); 385 | 386 | implement_from!( 387 | u22, 388 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21] 389 | ); 390 | implement_try_from!( 391 | u22, 392 | [ 393 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 394 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, 395 | u60, u61, u62, u63, usize 396 | ] 397 | ); 398 | 399 | implement_from!( 400 | u23, 401 | [u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22] 402 | ); 403 | implement_try_from!( 404 | u23, 405 | [ 406 | u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, 407 | u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, 408 | u61, u62, u63, usize 409 | ] 410 | ); 411 | 412 | implement_from!( 413 | u24, 414 | [ 415 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 416 | u23 417 | ] 418 | ); 419 | implement_try_from!( 420 | u24, 421 | [ 422 | u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, 423 | u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, 424 | u62, u63, usize 425 | ] 426 | ); 427 | 428 | implement_from!( 429 | u25, 430 | [ 431 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 432 | u23, u24 433 | ] 434 | ); 435 | implement_try_from!( 436 | u25, 437 | [ 438 | u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, 439 | u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, 440 | u63, usize 441 | ] 442 | ); 443 | 444 | implement_from!( 445 | u26, 446 | [ 447 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 448 | u23, u24, u25 449 | ] 450 | ); 451 | implement_try_from!( 452 | u26, 453 | [ 454 | u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, 455 | u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, 456 | usize 457 | ] 458 | ); 459 | 460 | implement_from!( 461 | u27, 462 | [ 463 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 464 | u23, u24, u25, u26 465 | ] 466 | ); 467 | implement_try_from!( 468 | u27, 469 | [ 470 | u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, 471 | u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 472 | ] 473 | ); 474 | 475 | implement_from!( 476 | u28, 477 | [ 478 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 479 | u23, u24, u25, u26, u27 480 | ] 481 | ); 482 | implement_try_from!( 483 | u28, 484 | [ 485 | u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, 486 | u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 487 | ] 488 | ); 489 | 490 | implement_from!( 491 | u29, 492 | [ 493 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 494 | u23, u24, u25, u26, u27, u28 495 | ] 496 | ); 497 | implement_try_from!( 498 | u29, 499 | [ 500 | u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, 501 | u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 502 | ] 503 | ); 504 | 505 | implement_from!( 506 | u30, 507 | [ 508 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 509 | u23, u24, u25, u26, u27, u28, u29 510 | ] 511 | ); 512 | implement_try_from!( 513 | u30, 514 | [ 515 | u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, 516 | u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 517 | ] 518 | ); 519 | 520 | implement_from!( 521 | u31, 522 | [ 523 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 524 | u23, u24, u25, u26, u27, u28, u29, u30 525 | ] 526 | ); 527 | implement_try_from!( 528 | u31, 529 | [ 530 | u33, u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, 531 | u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 532 | ] 533 | ); 534 | 535 | implement_from!( 536 | u33, 537 | [ 538 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 539 | u23, u24, u25, u26, u27, u28, u29, u30, u31 540 | ] 541 | ); 542 | implement_try_from!( 543 | u33, 544 | [ 545 | u34, u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, 546 | u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 547 | ] 548 | ); 549 | 550 | implement_from!( 551 | u34, 552 | [ 553 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 554 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33 555 | ] 556 | ); 557 | implement_try_from!( 558 | u34, 559 | [ 560 | u35, u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, 561 | u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 562 | ] 563 | ); 564 | 565 | implement_from!( 566 | u35, 567 | [ 568 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 569 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34 570 | ] 571 | ); 572 | implement_try_from!( 573 | u35, 574 | [ 575 | u36, u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, 576 | u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 577 | ] 578 | ); 579 | 580 | implement_from!( 581 | u36, 582 | [ 583 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 584 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35 585 | ] 586 | ); 587 | implement_try_from!( 588 | u36, 589 | [ 590 | u37, u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, 591 | u55, u56, u57, u58, u59, u60, u61, u62, u63, usize 592 | ] 593 | ); 594 | 595 | implement_from!( 596 | u37, 597 | [ 598 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 599 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36 600 | ] 601 | ); 602 | implement_try_from!( 603 | u37, 604 | [ 605 | u38, u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, 606 | u56, u57, u58, u59, u60, u61, u62, u63, usize 607 | ] 608 | ); 609 | 610 | implement_from!( 611 | u38, 612 | [ 613 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 614 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37 615 | ] 616 | ); 617 | implement_try_from!( 618 | u38, 619 | [ 620 | u39, u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, 621 | u57, u58, u59, u60, u61, u62, u63, usize 622 | ] 623 | ); 624 | 625 | implement_from!( 626 | u39, 627 | [ 628 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 629 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38 630 | ] 631 | ); 632 | implement_try_from!( 633 | u39, 634 | [ 635 | u40, u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, 636 | u58, u59, u60, u61, u62, u63, usize 637 | ] 638 | ); 639 | 640 | implement_from!( 641 | u40, 642 | [ 643 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 644 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39 645 | ] 646 | ); 647 | implement_try_from!( 648 | u40, 649 | [ 650 | u41, u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, 651 | u59, u60, u61, u62, u63, usize 652 | ] 653 | ); 654 | 655 | implement_from!( 656 | u41, 657 | [ 658 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 659 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40 660 | ] 661 | ); 662 | implement_try_from!( 663 | u41, 664 | [ 665 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, 666 | u60, u61, u62, u63, usize 667 | ] 668 | ); 669 | 670 | implement_from!( 671 | u42, 672 | [ 673 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 674 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41 675 | ] 676 | ); 677 | implement_try_from!( 678 | u42, 679 | [ 680 | u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, 681 | u61, u62, u63, usize 682 | ] 683 | ); 684 | 685 | implement_from!( 686 | u43, 687 | [ 688 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 689 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 690 | u42 691 | ] 692 | ); 693 | implement_try_from!( 694 | u43, 695 | [ 696 | u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, 697 | u62, u63, usize 698 | ] 699 | ); 700 | 701 | implement_from!( 702 | u44, 703 | [ 704 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 705 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 706 | u42, u43 707 | ] 708 | ); 709 | implement_try_from!( 710 | u44, 711 | [ 712 | u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, 713 | u63, usize 714 | ] 715 | ); 716 | 717 | implement_from!( 718 | u45, 719 | [ 720 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 721 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 722 | u42, u43, u44 723 | ] 724 | ); 725 | implement_try_from!( 726 | u45, 727 | [ 728 | u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, 729 | usize 730 | ] 731 | ); 732 | 733 | implement_from!( 734 | u46, 735 | [ 736 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 737 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 738 | u42, u43, u44, u45 739 | ] 740 | ); 741 | implement_try_from!( 742 | u46, 743 | [u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 744 | ); 745 | 746 | implement_from!( 747 | u47, 748 | [ 749 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 750 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 751 | u42, u43, u44, u45, u46 752 | ] 753 | ); 754 | implement_try_from!( 755 | u47, 756 | [u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 757 | ); 758 | 759 | implement_from!( 760 | u48, 761 | [ 762 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 763 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 764 | u42, u43, u44, u45, u46, u47 765 | ] 766 | ); 767 | implement_try_from!( 768 | u48, 769 | [u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 770 | ); 771 | 772 | implement_from!( 773 | u49, 774 | [ 775 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 776 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 777 | u42, u43, u44, u45, u46, u47, u48 778 | ] 779 | ); 780 | implement_try_from!( 781 | u49, 782 | [u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 783 | ); 784 | 785 | implement_from!( 786 | u50, 787 | [ 788 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 789 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 790 | u42, u43, u44, u45, u46, u47, u48, u49 791 | ] 792 | ); 793 | implement_try_from!( 794 | u50, 795 | [u51, u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 796 | ); 797 | 798 | implement_from!( 799 | u51, 800 | [ 801 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 802 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 803 | u42, u43, u44, u45, u46, u47, u48, u49, u50 804 | ] 805 | ); 806 | implement_try_from!( 807 | u51, 808 | [u52, u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 809 | ); 810 | 811 | implement_from!( 812 | u52, 813 | [ 814 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 815 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 816 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51 817 | ] 818 | ); 819 | implement_try_from!( 820 | u52, 821 | [u53, u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 822 | ); 823 | 824 | implement_from!( 825 | u53, 826 | [ 827 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 828 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 829 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52 830 | ] 831 | ); 832 | implement_try_from!( 833 | u53, 834 | [u54, u55, u56, u57, u58, u59, u60, u61, u62, u63, usize] 835 | ); 836 | 837 | implement_from!( 838 | u54, 839 | [ 840 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 841 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 842 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53 843 | ] 844 | ); 845 | implement_try_from!(u54, [u55, u56, u57, u58, u59, u60, u61, u62, u63, usize]); 846 | 847 | implement_from!( 848 | u55, 849 | [ 850 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 851 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 852 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54 853 | ] 854 | ); 855 | implement_try_from!(u55, [u56, u57, u58, u59, u60, u61, u62, u63, usize]); 856 | 857 | implement_from!( 858 | u56, 859 | [ 860 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 861 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 862 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55 863 | ] 864 | ); 865 | implement_try_from!(u56, [u57, u58, u59, u60, u61, u62, u63, usize]); 866 | 867 | implement_from!( 868 | u57, 869 | [ 870 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 871 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 872 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56 873 | ] 874 | ); 875 | implement_try_from!(u57, [u58, u59, u60, u61, u62, u63, usize]); 876 | 877 | implement_from!( 878 | u58, 879 | [ 880 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 881 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 882 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57 883 | ] 884 | ); 885 | implement_try_from!(u58, [u59, u60, u61, u62, u63, usize]); 886 | 887 | implement_from!( 888 | u59, 889 | [ 890 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 891 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 892 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58 893 | ] 894 | ); 895 | implement_try_from!(u59, [u60, u61, u62, u63, usize]); 896 | 897 | implement_from!( 898 | u60, 899 | [ 900 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 901 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 902 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59 903 | ] 904 | ); 905 | implement_try_from!(u60, [u61, u62, u63, usize]); 906 | 907 | implement_from!( 908 | u61, 909 | [ 910 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 911 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 912 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, 913 | u60 914 | ] 915 | ); 916 | implement_try_from!(u61, [u62, u63, usize]); 917 | 918 | implement_from!( 919 | u62, 920 | [ 921 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 922 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 923 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, 924 | u60, u61 925 | ] 926 | ); 927 | implement_from!( 928 | u63, 929 | [ 930 | u1, u2, u3, u4, u5, u6, u7, u9, u10, u11, u12, u13, u14, u15, u17, u18, u19, u20, u21, u22, 931 | u23, u24, u25, u26, u27, u28, u29, u30, u31, u33, u34, u35, u36, u37, u38, u39, u40, u41, 932 | u42, u43, u44, u45, u46, u47, u48, u49, u50, u51, u52, u53, u54, u55, u56, u57, u58, u59, 933 | u60, u61, u62 934 | ] 935 | ); 936 | 937 | // Implement From for all signed integer 938 | 939 | implement_try_from!([i2, i3, i4, i5, i6, i7], i8); 940 | implement_from!([i9, i10, i11, i12, i13, i14, i15], i8); 941 | implement_from!([i17, i18, i19, i20, i21, i22, i23, i24], i8); 942 | implement_from!([i25, i26, i27, i28, i29, i30, i31], i8); 943 | implement_from!([i33, i34, i35, i36, i37, i38, i39, i40], i8); 944 | implement_from!([i41, i42, i43, i44, i45, i46, i47, i48], i8); 945 | implement_from!([i49, i50, i51, i52, i53, i54, i55, i56], i8); 946 | implement_from!([i57, i58, i59, i60, i61, i62, i63], i8); 947 | 948 | implement_into!([i2, i3, i4, i5, i6, i7], i8); 949 | implement_try_into!([i9, i10, i11, i12, i13, i14, i15], i8); 950 | implement_try_into!([i17, i18, i19, i20, i21, i22, i23, i24], i8); 951 | implement_try_into!([i25, i26, i27, i28, i29, i30, i31], i8); 952 | implement_try_into!([i33, i34, i35, i36, i37, i38, i39, i40], i8); 953 | implement_try_into!([i41, i42, i43, i44, i45, i46, i47, i48], i8); 954 | implement_try_into!([i49, i50, i51, i52, i53, i54, i55, i56], i8); 955 | implement_try_into!([i57, i58, i59, i60, i61, i62, i63], i8); 956 | 957 | implement_try_from!([i2, i3, i4, i5, i6, i7], i16); 958 | implement_try_from!([i9, i10, i11, i12, i13, i14, i15], i16); 959 | implement_from!([i17, i18, i19, i20, i21, i22, i23, i24], i16); 960 | implement_from!([i25, i26, i27, i28, i29, i30, i31], i16); 961 | implement_from!([i33, i34, i35, i36, i37, i38, i39, i40], i16); 962 | implement_from!([i41, i42, i43, i44, i45, i46, i47, i48], i16); 963 | implement_from!([i49, i50, i51, i52, i53, i54, i55, i56], i16); 964 | implement_from!([i57, i58, i59, i60, i61, i62, i63], i16); 965 | 966 | implement_into!([i2, i3, i4, i5, i6, i7], i16); 967 | implement_into!([i9, i10, i11, i12, i13, i14, i15], i16); 968 | implement_try_into!([i17, i18, i19, i20, i21, i22, i23, i24], i16); 969 | implement_try_into!([i25, i26, i27, i28, i29, i30, i31], i16); 970 | implement_try_into!([i33, i34, i35, i36, i37, i38, i39, i40], i16); 971 | implement_try_into!([i41, i42, i43, i44, i45, i46, i47, i48], i16); 972 | implement_try_into!([i49, i50, i51, i52, i53, i54, i55, i56], i16); 973 | implement_try_into!([i57, i58, i59, i60, i61, i62, i63], i16); 974 | 975 | implement_try_from!([i2, i3, i4, i5, i6, i7], i32); 976 | implement_try_from!([i9, i10, i11, i12, i13, i14, i15], i32); 977 | implement_try_from!([i17, i18, i19, i20, i21, i22, i23, i24], i32); 978 | implement_try_from!([i25, i26, i27, i28, i29, i30, i31], i32); 979 | implement_from!([i33, i34, i35, i36, i37, i38, i39, i40], i32); 980 | implement_from!([i41, i42, i43, i44, i45, i46, i47, i48], i32); 981 | implement_from!([i49, i50, i51, i52, i53, i54, i55, i56], i32); 982 | implement_from!([i57, i58, i59, i60, i61, i62, i63], i32); 983 | 984 | implement_into!([i2, i3, i4, i5, i6, i7], i32); 985 | implement_into!([i9, i10, i11, i12, i13, i14, i15], i32); 986 | implement_into!([i17, i18, i19, i20, i21, i22, i23, i24], i32); 987 | implement_into!([i25, i26, i27, i28, i29, i30, i31], i32); 988 | implement_try_into!([i33, i34, i35, i36, i37, i38, i39, i40], i32); 989 | implement_try_into!([i41, i42, i43, i44, i45, i46, i47, i48], i32); 990 | implement_try_into!([i49, i50, i51, i52, i53, i54, i55, i56], i32); 991 | implement_try_into!([i57, i58, i59, i60, i61, i62, i63], i32); 992 | 993 | implement_try_from!([i2, i3, i4, i5, i6, i7], i64); 994 | implement_try_from!([i9, i10, i11, i12, i13, i14, i15], i64); 995 | implement_try_from!([i17, i18, i19, i20, i21, i22, i23, i24], i64); 996 | implement_try_from!([i25, i26, i27, i28, i29, i30, i31], i64); 997 | implement_try_from!([i33, i34, i35, i36, i37, i38, i39, i40], i64); 998 | implement_try_from!([i41, i42, i43, i44, i45, i46, i47, i48], i64); 999 | implement_try_from!([i49, i50, i51, i52, i53, i54, i55, i56], i64); 1000 | implement_try_from!([i57, i58, i59, i60, i61, i62, i63], i64); 1001 | 1002 | implement_into!([i2, i3, i4, i5, i6, i7], i64); 1003 | implement_into!([i9, i10, i11, i12, i13, i14, i15], i64); 1004 | implement_into!([i17, i18, i19, i20, i21, i22, i23, i24], i64); 1005 | implement_into!([i25, i26, i27, i28, i29, i30, i31], i64); 1006 | implement_into!([i33, i34, i35, i36, i37, i38, i39, i40], i64); 1007 | implement_into!([i41, i42, i43, i44, i45, i46, i47, i48], i64); 1008 | implement_into!([i49, i50, i51, i52, i53, i54, i55, i56], i64); 1009 | implement_into!([i57, i58, i59, i60, i61, i62, i63], i64); 1010 | 1011 | implement_try_from!( 1012 | i2, 1013 | [ 1014 | i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, 1015 | i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, 1016 | i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, 1017 | i61, i62, i63 1018 | ] 1019 | ); 1020 | 1021 | implement_from!(i3, [i2]); 1022 | implement_try_from!( 1023 | i3, 1024 | [ 1025 | i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, 1026 | i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, 1027 | i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, 1028 | i62, i63 1029 | ] 1030 | ); 1031 | 1032 | implement_from!(i4, [i2, i3]); 1033 | implement_try_from!( 1034 | i4, 1035 | [ 1036 | i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, 1037 | i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, 1038 | i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, 1039 | i63 1040 | ] 1041 | ); 1042 | 1043 | implement_from!(i5, [i2, i3, i4]); 1044 | implement_try_from!( 1045 | i5, 1046 | [ 1047 | i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, 1048 | i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, 1049 | i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1050 | ] 1051 | ); 1052 | 1053 | implement_from!(i6, [i2, i3, i4, i5]); 1054 | implement_try_from!( 1055 | i6, 1056 | [ 1057 | i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, 1058 | i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, 1059 | i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1060 | ] 1061 | ); 1062 | 1063 | implement_from!(i7, [i2, i3, i4, i5, i6]); 1064 | implement_try_from!( 1065 | i7, 1066 | [ 1067 | i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, 1068 | i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, 1069 | i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1070 | ] 1071 | ); 1072 | 1073 | implement_from!(i9, [i2, i3, i4, i5, i6, i7]); 1074 | implement_try_from!( 1075 | i9, 1076 | [ 1077 | i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, 1078 | i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, 1079 | i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1080 | ] 1081 | ); 1082 | 1083 | implement_from!(i10, [i2, i3, i4, i5, i6, i7, i9]); 1084 | implement_try_from!( 1085 | i10, 1086 | [ 1087 | i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, 1088 | i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, 1089 | i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1090 | ] 1091 | ); 1092 | 1093 | implement_from!(i11, [i2, i3, i4, i5, i6, i7, i9, i10]); 1094 | implement_try_from!( 1095 | i11, 1096 | [ 1097 | i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, 1098 | i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, 1099 | i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1100 | ] 1101 | ); 1102 | 1103 | implement_from!(i12, [i2, i3, i4, i5, i6, i7, i9, i10, i11]); 1104 | implement_try_from!( 1105 | i12, 1106 | [ 1107 | i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, 1108 | i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, 1109 | i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1110 | ] 1111 | ); 1112 | 1113 | implement_from!(i13, [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12]); 1114 | implement_try_from!( 1115 | i13, 1116 | [ 1117 | i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, 1118 | i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, 1119 | i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1120 | ] 1121 | ); 1122 | 1123 | implement_from!(i14, [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13]); 1124 | implement_try_from!( 1125 | i14, 1126 | [ 1127 | i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, 1128 | i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, 1129 | i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1130 | ] 1131 | ); 1132 | 1133 | implement_from!(i15, [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14]); 1134 | implement_try_from!( 1135 | i15, 1136 | [ 1137 | i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, 1138 | i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, 1139 | i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1140 | ] 1141 | ); 1142 | 1143 | implement_from!( 1144 | i17, 1145 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15] 1146 | ); 1147 | implement_try_from!( 1148 | i17, 1149 | [ 1150 | i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, 1151 | i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, 1152 | i55, i56, i57, i58, i59, i60, i61, i62, i63 1153 | ] 1154 | ); 1155 | 1156 | implement_from!( 1157 | i18, 1158 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17] 1159 | ); 1160 | implement_try_from!( 1161 | i18, 1162 | [ 1163 | i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, 1164 | i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, 1165 | i56, i57, i58, i59, i60, i61, i62, i63 1166 | ] 1167 | ); 1168 | 1169 | implement_from!( 1170 | i19, 1171 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18] 1172 | ); 1173 | implement_try_from!( 1174 | i19, 1175 | [ 1176 | i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, 1177 | i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, 1178 | i57, i58, i59, i60, i61, i62, i63 1179 | ] 1180 | ); 1181 | 1182 | implement_from!( 1183 | i20, 1184 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19] 1185 | ); 1186 | implement_try_from!( 1187 | i20, 1188 | [ 1189 | i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, 1190 | i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, 1191 | i58, i59, i60, i61, i62, i63 1192 | ] 1193 | ); 1194 | 1195 | implement_from!( 1196 | i21, 1197 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20] 1198 | ); 1199 | implement_try_from!( 1200 | i21, 1201 | [ 1202 | i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, 1203 | i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, 1204 | i59, i60, i61, i62, i63 1205 | ] 1206 | ); 1207 | 1208 | implement_from!( 1209 | i22, 1210 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21] 1211 | ); 1212 | implement_try_from!( 1213 | i22, 1214 | [ 1215 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1216 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, 1217 | i60, i61, i62, i63 1218 | ] 1219 | ); 1220 | 1221 | implement_from!( 1222 | i23, 1223 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22] 1224 | ); 1225 | implement_try_from!( 1226 | i23, 1227 | [ 1228 | i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, 1229 | i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, 1230 | i61, i62, i63 1231 | ] 1232 | ); 1233 | 1234 | implement_from!( 1235 | i24, 1236 | [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23] 1237 | ); 1238 | implement_try_from!( 1239 | i24, 1240 | [ 1241 | i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, 1242 | i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, 1243 | i62, i63 1244 | ] 1245 | ); 1246 | 1247 | implement_from!( 1248 | i25, 1249 | [ 1250 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1251 | i23, i24 1252 | ] 1253 | ); 1254 | implement_try_from!( 1255 | i25, 1256 | [ 1257 | i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, 1258 | i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, 1259 | i63 1260 | ] 1261 | ); 1262 | 1263 | implement_from!( 1264 | i26, 1265 | [ 1266 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1267 | i23, i24, i25 1268 | ] 1269 | ); 1270 | implement_try_from!( 1271 | i26, 1272 | [ 1273 | i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, 1274 | i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1275 | ] 1276 | ); 1277 | 1278 | implement_from!( 1279 | i27, 1280 | [ 1281 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1282 | i23, i24, i25, i26 1283 | ] 1284 | ); 1285 | implement_try_from!( 1286 | i27, 1287 | [ 1288 | i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, 1289 | i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1290 | ] 1291 | ); 1292 | 1293 | implement_from!( 1294 | i28, 1295 | [ 1296 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1297 | i23, i24, i25, i26, i27 1298 | ] 1299 | ); 1300 | implement_try_from!( 1301 | i28, 1302 | [ 1303 | i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, 1304 | i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1305 | ] 1306 | ); 1307 | 1308 | implement_from!( 1309 | i29, 1310 | [ 1311 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1312 | i23, i24, i25, i26, i27, i28 1313 | ] 1314 | ); 1315 | implement_try_from!( 1316 | i29, 1317 | [ 1318 | i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, 1319 | i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1320 | ] 1321 | ); 1322 | 1323 | implement_from!( 1324 | i30, 1325 | [ 1326 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1327 | i23, i24, i25, i26, i27, i28, i29 1328 | ] 1329 | ); 1330 | implement_try_from!( 1331 | i30, 1332 | [ 1333 | i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, 1334 | i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1335 | ] 1336 | ); 1337 | 1338 | implement_from!( 1339 | i31, 1340 | [ 1341 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1342 | i23, i24, i25, i26, i27, i28, i29, i30 1343 | ] 1344 | ); 1345 | implement_try_from!( 1346 | i31, 1347 | [ 1348 | i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, 1349 | i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1350 | ] 1351 | ); 1352 | 1353 | implement_from!( 1354 | i33, 1355 | [ 1356 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1357 | i23, i24, i25, i26, i27, i28, i29, i30, i31 1358 | ] 1359 | ); 1360 | implement_try_from!( 1361 | i33, 1362 | [ 1363 | i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, 1364 | i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1365 | ] 1366 | ); 1367 | 1368 | implement_from!( 1369 | i34, 1370 | [ 1371 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1372 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33 1373 | ] 1374 | ); 1375 | implement_try_from!( 1376 | i34, 1377 | [ 1378 | i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, 1379 | i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1380 | ] 1381 | ); 1382 | 1383 | implement_from!( 1384 | i35, 1385 | [ 1386 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1387 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34 1388 | ] 1389 | ); 1390 | implement_try_from!( 1391 | i35, 1392 | [ 1393 | i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, 1394 | i54, i55, i56, i57, i58, i59, i60, i61, i62, i63 1395 | ] 1396 | ); 1397 | 1398 | implement_from!( 1399 | i36, 1400 | [ 1401 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1402 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35 1403 | ] 1404 | ); 1405 | implement_try_from!( 1406 | i36, 1407 | [ 1408 | i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, 1409 | i55, i56, i57, i58, i59, i60, i61, i62, i63 1410 | ] 1411 | ); 1412 | 1413 | implement_from!( 1414 | i37, 1415 | [ 1416 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1417 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36 1418 | ] 1419 | ); 1420 | implement_try_from!( 1421 | i37, 1422 | [ 1423 | i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, 1424 | i56, i57, i58, i59, i60, i61, i62, i63 1425 | ] 1426 | ); 1427 | 1428 | implement_from!( 1429 | i38, 1430 | [ 1431 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1432 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37 1433 | ] 1434 | ); 1435 | implement_try_from!( 1436 | i38, 1437 | [ 1438 | i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, 1439 | i57, i58, i59, i60, i61, i62, i63 1440 | ] 1441 | ); 1442 | 1443 | implement_from!( 1444 | i39, 1445 | [ 1446 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1447 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38 1448 | ] 1449 | ); 1450 | implement_try_from!( 1451 | i39, 1452 | [ 1453 | i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, 1454 | i58, i59, i60, i61, i62, i63 1455 | ] 1456 | ); 1457 | 1458 | implement_from!( 1459 | i40, 1460 | [ 1461 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1462 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39 1463 | ] 1464 | ); 1465 | implement_try_from!( 1466 | i40, 1467 | [ 1468 | i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, 1469 | i59, i60, i61, i62, i63 1470 | ] 1471 | ); 1472 | 1473 | implement_from!( 1474 | i41, 1475 | [ 1476 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1477 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40 1478 | ] 1479 | ); 1480 | implement_try_from!( 1481 | i41, 1482 | [ 1483 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, 1484 | i60, i61, i62, i63 1485 | ] 1486 | ); 1487 | 1488 | implement_from!( 1489 | i42, 1490 | [ 1491 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1492 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41 1493 | ] 1494 | ); 1495 | implement_try_from!( 1496 | i42, 1497 | [ 1498 | i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, 1499 | i61, i62, i63 1500 | ] 1501 | ); 1502 | 1503 | implement_from!( 1504 | i43, 1505 | [ 1506 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1507 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1508 | i42 1509 | ] 1510 | ); 1511 | implement_try_from!( 1512 | i43, 1513 | [ 1514 | i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, 1515 | i62, i63 1516 | ] 1517 | ); 1518 | 1519 | implement_from!( 1520 | i44, 1521 | [ 1522 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1523 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1524 | i42, i43 1525 | ] 1526 | ); 1527 | implement_try_from!( 1528 | i44, 1529 | [ 1530 | i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, 1531 | i63 1532 | ] 1533 | ); 1534 | 1535 | implement_from!( 1536 | i45, 1537 | [ 1538 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1539 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1540 | i42, i43, i44 1541 | ] 1542 | ); 1543 | implement_try_from!( 1544 | i45, 1545 | [i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63] 1546 | ); 1547 | 1548 | implement_from!( 1549 | i46, 1550 | [ 1551 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1552 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1553 | i42, i43, i44, i45 1554 | ] 1555 | ); 1556 | implement_try_from!( 1557 | i46, 1558 | [i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63] 1559 | ); 1560 | 1561 | implement_from!( 1562 | i47, 1563 | [ 1564 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1565 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1566 | i42, i43, i44, i45, i46 1567 | ] 1568 | ); 1569 | implement_try_from!( 1570 | i47, 1571 | [i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63] 1572 | ); 1573 | 1574 | implement_from!( 1575 | i48, 1576 | [ 1577 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1578 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1579 | i42, i43, i44, i45, i46, i47 1580 | ] 1581 | ); 1582 | implement_try_from!( 1583 | i48, 1584 | [i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63] 1585 | ); 1586 | 1587 | implement_from!( 1588 | i49, 1589 | [ 1590 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1591 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1592 | i42, i43, i44, i45, i46, i47, i48 1593 | ] 1594 | ); 1595 | implement_try_from!( 1596 | i49, 1597 | [i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63] 1598 | ); 1599 | 1600 | implement_from!( 1601 | i50, 1602 | [ 1603 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1604 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1605 | i42, i43, i44, i45, i46, i47, i48, i49 1606 | ] 1607 | ); 1608 | implement_try_from!( 1609 | i50, 1610 | [i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63] 1611 | ); 1612 | 1613 | implement_from!( 1614 | i51, 1615 | [ 1616 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1617 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1618 | i42, i43, i44, i45, i46, i47, i48, i49, i50 1619 | ] 1620 | ); 1621 | implement_try_from!( 1622 | i51, 1623 | [i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63] 1624 | ); 1625 | 1626 | implement_from!( 1627 | i52, 1628 | [ 1629 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1630 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1631 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51 1632 | ] 1633 | ); 1634 | implement_try_from!(i52, [i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63]); 1635 | 1636 | implement_from!( 1637 | i53, 1638 | [ 1639 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1640 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1641 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52 1642 | ] 1643 | ); 1644 | implement_try_from!(i53, [i54, i55, i56, i57, i58, i59, i60, i61, i62, i63]); 1645 | 1646 | implement_from!( 1647 | i54, 1648 | [ 1649 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1650 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1651 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53 1652 | ] 1653 | ); 1654 | implement_try_from!(i54, [i55, i56, i57, i58, i59, i60, i61, i62, i63]); 1655 | 1656 | implement_from!( 1657 | i55, 1658 | [ 1659 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1660 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1661 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54 1662 | ] 1663 | ); 1664 | implement_try_from!(i55, [i56, i57, i58, i59, i60, i61, i62, i63]); 1665 | 1666 | implement_from!( 1667 | i56, 1668 | [ 1669 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1670 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1671 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55 1672 | ] 1673 | ); 1674 | implement_try_from!(i56, [i57, i58, i59, i60, i61, i62, i63]); 1675 | 1676 | implement_from!( 1677 | i57, 1678 | [ 1679 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1680 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1681 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56 1682 | ] 1683 | ); 1684 | implement_try_from!(i57, [i58, i59, i60, i61, i62, i63]); 1685 | 1686 | implement_from!( 1687 | i58, 1688 | [ 1689 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1690 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1691 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57 1692 | ] 1693 | ); 1694 | implement_try_from!(i58, [i59, i60, i61, i62, i63]); 1695 | 1696 | implement_from!( 1697 | i59, 1698 | [ 1699 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1700 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1701 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58 1702 | ] 1703 | ); 1704 | implement_try_from!(i59, [i60, i61, i62, i63]); 1705 | 1706 | implement_from!( 1707 | i60, 1708 | [ 1709 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1710 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1711 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59 1712 | ] 1713 | ); 1714 | implement_try_from!(i60, [i61, i62, i63]); 1715 | 1716 | implement_from!( 1717 | i61, 1718 | [ 1719 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1720 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1721 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, 1722 | i60 1723 | ] 1724 | ); 1725 | implement_try_from!(i61, [i62, i63]); 1726 | 1727 | implement_from!( 1728 | i62, 1729 | [ 1730 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1731 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1732 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, 1733 | i60, i61 1734 | ] 1735 | ); 1736 | implement_from!( 1737 | i63, 1738 | [ 1739 | i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, 1740 | i23, i24, i25, i26, i27, i28, i29, i30, i31, i33, i34, i35, i36, i37, i38, i39, i40, i41, 1741 | i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, 1742 | i60, i61, i62 1743 | ] 1744 | ); 1745 | 1746 | impl From for u1 { 1747 | fn from(b: bool) -> Self { 1748 | match b { 1749 | true => u1(1), 1750 | false => u1(0), 1751 | } 1752 | } 1753 | } 1754 | 1755 | impl From for bool { 1756 | fn from(u1(x): u1) -> Self { 1757 | match x { 1758 | 0 => false, 1759 | 1 => true, 1760 | _ => unreachable!(), 1761 | } 1762 | } 1763 | } 1764 | 1765 | #[cfg(test)] 1766 | mod tests { 1767 | use super::*; 1768 | 1769 | #[test] 1770 | fn test_infallible_conversion_unsigned() { 1771 | assert_eq!(u16::from(u9(12)), 12u16); 1772 | assert_eq!(u32::from(u9(12)), 12u32); 1773 | 1774 | assert_eq!(u9(127), 127u8.into()); 1775 | 1776 | assert_eq!(u7::from(u6(65)), u7(65)); 1777 | } 1778 | 1779 | #[test] 1780 | fn test_infallible_conversion_signed() { 1781 | assert_eq!(i16::from(i9(12)), 12i16); 1782 | assert_eq!(i32::from(i9(12)), 12i32); 1783 | 1784 | assert_eq!(i16::from(i9(-12)), -12i16); 1785 | assert_eq!(i32::from(i9(-12)), -12i32); 1786 | 1787 | assert_eq!(i9(127), 127i8.into()); 1788 | 1789 | assert_eq!(i7::from(i6(65)), i7(65)); 1790 | assert_eq!(i7::from(i6(-65)), i7(-65)); 1791 | } 1792 | 1793 | #[test] 1794 | fn test_fallible_conversion_unsigned() { 1795 | assert_eq!(u16::try_from(u9(12)), Ok(12u16)); 1796 | assert_eq!(u32::try_from(u9(12)), Ok(12u32)); 1797 | 1798 | assert_eq!(127u8.try_into(), Ok(u9(127))); 1799 | 1800 | assert_eq!(u7::try_from(u6(65)), Ok(u7(65))); 1801 | 1802 | assert!(u16::try_from(u19(0x1_ffff)).is_err()); 1803 | assert!(u32::try_from(u39(0x1_fffff_ffff)).is_err()); 1804 | 1805 | assert!(u6::try_from(u7(127)).is_err()); 1806 | 1807 | assert_eq!(u2::try_from(1usize), Ok(u2(1))); 1808 | assert!(u2::try_from(4usize).is_err()); 1809 | assert_eq!(u2(1).try_into(), Ok(1usize)); 1810 | 1811 | // Make sure that uX types behave the same as standard types with regards to usize 1812 | // conversion. 1813 | assert_eq!( 1814 | usize::try_from(0x1_FFFF_FFFFu64).is_err(), 1815 | usize::try_from(u33::MAX).is_err() 1816 | ); 1817 | } 1818 | 1819 | #[test] 1820 | fn test_fallible_conversion_signed() { 1821 | assert_eq!(i16::try_from(i9(12)), Ok(12i16)); 1822 | assert_eq!(i32::try_from(i9(12)), Ok(12i32)); 1823 | 1824 | assert_eq!(i16::try_from(i9(-12)), Ok(-12i16)); 1825 | assert_eq!(i32::try_from(i9(-12)), Ok(-12i32)); 1826 | 1827 | assert_eq!(127i8.try_into(), Ok(i9(127))); 1828 | 1829 | assert_eq!(i7::try_from(i6(65)), Ok(i7(65))); 1830 | assert_eq!(i7::try_from(i6(-65)), Ok(i7(-65))); 1831 | 1832 | assert!(i16::try_from(i19(0xffff)).is_err()); 1833 | assert!(i32::try_from(i39(0xffff_ffff)).is_err()); 1834 | 1835 | assert!(i16::try_from(i19(-0xffff)).is_err()); 1836 | assert!(i32::try_from(i39(-0xffff_ffff)).is_err()); 1837 | 1838 | assert!(i6::try_from(i7(64)).is_err()); 1839 | assert!(i6::try_from(i7(-64)).is_err()); 1840 | } 1841 | 1842 | #[test] 1843 | #[cfg(feature = "std")] 1844 | fn error_trait() { 1845 | assert_eq!( 1846 | (&TryFromIntError(()) as &dyn std::error::Error).to_string(), 1847 | "out of range integral type conversion attempted" 1848 | ); 1849 | } 1850 | } 1851 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # uX - non-standard-width integers types 2 | //! 3 | //! When non-standard-width integers is required in an applications, the norm is to use a larger container and make sure the value is within range after manipulation. uX aims to take care of this once and for all by: 4 | //! 5 | //! - Providing `u1`-`u127` and `i1`-`i127` types that should behave as similar as possible to the built in rust types 6 | //! - The methods of the defined types are the same as for the built in types (far from all is implemented at this point but fill out an issue or create a PR if something essential for you is missing) 7 | //! - Overflow will panic in debug and wrap in release. 8 | //! - All possible infallible conversions is possible by using `From` and all fallible conversion by using `TryFrom`. 9 | //! 10 | //! The uX types take up as much space as the smallest integer type that can contain them; 11 | //! the compiler can not yet be made aware of further optimization potential, 12 | //! and thus does not use it: 13 | //! an `Option` still takes up two bytes. 14 | 15 | #![cfg_attr(not(feature = "std"), no_std)] 16 | 17 | mod lib { 18 | pub use core; 19 | } 20 | 21 | mod conversion; 22 | 23 | use lib::core::ops::{ 24 | BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not, Shl, ShlAssign, Shr, 25 | ShrAssign, 26 | }; 27 | 28 | use lib::core::fmt::{Binary, Display, Formatter, LowerHex, Octal, UpperHex}; 29 | 30 | macro_rules! define_unsigned { 31 | ($name:ident, $bits:expr, $type:ident) => {define_unsigned!(#[doc=""], $name, $bits, $type);}; 32 | (#[$doc:meta], $name:ident, $bits:expr, $type:ident) => { 33 | 34 | #[$doc] 35 | #[allow(non_camel_case_types)] 36 | #[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 37 | pub struct $name($type); 38 | 39 | impl $name { 40 | pub const MAX: Self = $name(((1 as $type) << $bits) -1 ); 41 | pub const MIN: Self = $name(0); 42 | pub const BITS: u32 = $bits; 43 | 44 | fn mask(self) -> Self { 45 | $name(self.0 & ( ((1 as $type) << $bits).overflowing_sub(1).0)) 46 | } 47 | } 48 | 49 | implement_common!($name, $bits, $type); 50 | 51 | } 52 | } 53 | 54 | macro_rules! define_signed { 55 | ($name:ident, $bits:expr, $type:ident) => {define_signed!(#[doc=""], $name, $bits, $type);}; 56 | (#[$doc:meta], $name:ident, $bits:expr, $type:ident) => { 57 | 58 | #[$doc] 59 | #[allow(non_camel_case_types)] 60 | #[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 61 | pub struct $name($type); 62 | 63 | #[$doc] 64 | impl $name { 65 | pub const MAX: Self = $name(((1 as $type) << ($bits - 1)) - 1); 66 | pub const MIN: Self = $name(-((1 as $type) << ($bits - 1))); 67 | pub const BITS: u32 = $bits; 68 | 69 | fn mask(self) -> Self { 70 | if ( self.0 & (1<<($bits-1)) ) == 0 { 71 | $name(self.0 & ( ((1 as $type) << $bits).overflowing_sub(1).0)) 72 | } else { 73 | $name(self.0 | !( ((1 as $type) << $bits).overflowing_sub(1).0)) 74 | } 75 | } 76 | } 77 | 78 | implement_common!($name, $bits, $type); 79 | 80 | } 81 | } 82 | 83 | macro_rules! implement_common { 84 | ($name:ident, $bits:expr, $type:ident) => { 85 | impl $name { 86 | /// Returns the smallest value that can be represented by this integer type. 87 | pub fn min_value() -> $name { 88 | $name::MIN 89 | } 90 | /// Returns the largest value that can be represented by this integer type. 91 | pub fn max_value() -> $name { 92 | $name::MAX 93 | } 94 | 95 | /// Crates a new variable 96 | /// 97 | /// This function mainly exists as there is currently not a better way to construct these types. 98 | /// May be deprecated or removed if a better way to construct these types becomes available. 99 | /// 100 | /// # Examples 101 | /// 102 | /// Basic usage: 103 | /// 104 | /// ``` 105 | /// use ux::*; 106 | /// 107 | /// assert_eq!(u31::new(64), u31::from(64u8)); 108 | /// 109 | /// ``` 110 | /// 111 | /// # Panic 112 | /// 113 | /// This function will panic if `value` is not representable by this type 114 | pub const fn new(value: $type) -> $name { 115 | assert!(value <= $name::MAX.0 && value >= $name::MIN.0); 116 | $name(value) 117 | } 118 | 119 | /// Wrapping (modular) subtraction. Computes `self - other`, 120 | /// wrapping around at the boundary of the type. 121 | /// 122 | /// # Examples 123 | /// 124 | /// Basic usage: 125 | /// 126 | /// ``` 127 | /// use ux::*; 128 | /// 129 | /// assert_eq!(i5::MIN.wrapping_sub(i5::new(1)), i5::MAX); 130 | /// 131 | /// assert_eq!(i5::new(-10).wrapping_sub(i5::new(5)), i5::new(-15)); 132 | /// assert_eq!(i5::new(-15).wrapping_sub(i5::new(5)), i5::new(12)); 133 | /// ``` 134 | pub fn wrapping_sub(self, rhs: Self) -> Self { 135 | $name(self.0.wrapping_sub(rhs.0)).mask() 136 | } 137 | 138 | /// Wrapping (modular) addition. Computes `self + other`, 139 | /// wrapping around at the boundary of the type. 140 | /// 141 | /// # Examples 142 | /// 143 | /// Basic usage: 144 | /// 145 | /// ``` 146 | /// use ux::*; 147 | /// 148 | /// assert_eq!(i5::MAX.wrapping_add(i5::new(1)), i5::MIN); 149 | /// 150 | /// assert_eq!(i5::new(10).wrapping_add(i5::new(5)), i5::new(15)); 151 | /// assert_eq!(i5::new(15).wrapping_add(i5::new(5)), i5::new(-12)); 152 | /// ``` 153 | pub fn wrapping_add(self, rhs: Self) -> Self { 154 | $name(self.0.wrapping_add(rhs.0)).mask() 155 | } 156 | } 157 | 158 | // Implement formating functions 159 | impl Display for $name { 160 | fn fmt(&self, f: &mut Formatter) -> Result<(), lib::core::fmt::Error> { 161 | let $name(ref value) = self; 162 | <$type as Display>::fmt(value, f) 163 | } 164 | } 165 | impl UpperHex for $name { 166 | fn fmt(&self, f: &mut Formatter) -> Result<(), lib::core::fmt::Error> { 167 | let $name(ref value) = self; 168 | <$type as UpperHex>::fmt(value, f) 169 | } 170 | } 171 | impl LowerHex for $name { 172 | fn fmt(&self, f: &mut Formatter) -> Result<(), lib::core::fmt::Error> { 173 | let $name(ref value) = self; 174 | <$type as LowerHex>::fmt(value, f) 175 | } 176 | } 177 | impl Octal for $name { 178 | fn fmt(&self, f: &mut Formatter) -> Result<(), lib::core::fmt::Error> { 179 | let $name(ref value) = self; 180 | <$type as Octal>::fmt(value, f) 181 | } 182 | } 183 | impl Binary for $name { 184 | fn fmt(&self, f: &mut Formatter) -> Result<(), lib::core::fmt::Error> { 185 | let $name(ref value) = self; 186 | <$type as Binary>::fmt(value, f) 187 | } 188 | } 189 | 190 | impl Shr for $name 191 | where 192 | $type: Shr, 193 | { 194 | type Output = $name; 195 | 196 | fn shr(self, rhs: T) -> $name { 197 | $name(self.0.shr(rhs)) 198 | } 199 | } 200 | 201 | impl Shl for $name 202 | where 203 | $type: Shl, 204 | { 205 | type Output = $name; 206 | 207 | fn shl(self, rhs: T) -> $name { 208 | $name(self.0.shl(rhs)).mask() 209 | } 210 | } 211 | 212 | impl ShrAssign for $name 213 | where 214 | $type: ShrAssign, 215 | { 216 | fn shr_assign(&mut self, rhs: T) { 217 | self.0.shr_assign(rhs); 218 | } 219 | } 220 | 221 | impl ShlAssign for $name 222 | where 223 | $type: ShlAssign, 224 | { 225 | fn shl_assign(&mut self, rhs: T) { 226 | self.0.shl_assign(rhs); 227 | *self = self.mask(); 228 | } 229 | } 230 | 231 | impl BitOr<$name> for $name { 232 | type Output = $name; 233 | 234 | fn bitor(self, rhs: $name) -> Self::Output { 235 | $name(self.0.bitor(rhs.0)) 236 | } 237 | } 238 | 239 | impl<'a> BitOr<&'a $name> for $name { 240 | type Output = <$name as BitOr<$name>>::Output; 241 | 242 | fn bitor(self, rhs: &'a $name) -> Self::Output { 243 | $name(self.0.bitor(rhs.0)) 244 | } 245 | } 246 | 247 | impl<'a> BitOr<$name> for &'a $name { 248 | type Output = <$name as BitOr<$name>>::Output; 249 | 250 | fn bitor(self, rhs: $name) -> Self::Output { 251 | $name(self.0.bitor(rhs.0)) 252 | } 253 | } 254 | 255 | impl<'a> BitOr<&'a $name> for &'a $name { 256 | type Output = <$name as BitOr<$name>>::Output; 257 | 258 | fn bitor(self, rhs: &'a $name) -> Self::Output { 259 | $name(self.0.bitor(rhs.0)) 260 | } 261 | } 262 | 263 | impl BitOrAssign<$name> for $name { 264 | fn bitor_assign(&mut self, other: $name) { 265 | self.0.bitor_assign(other.0) 266 | } 267 | } 268 | 269 | impl BitXor<$name> for $name { 270 | type Output = $name; 271 | 272 | fn bitxor(self, rhs: $name) -> Self::Output { 273 | $name(self.0.bitxor(rhs.0)) 274 | } 275 | } 276 | 277 | impl<'a> BitXor<&'a $name> for $name { 278 | type Output = <$name as BitOr<$name>>::Output; 279 | 280 | fn bitxor(self, rhs: &'a $name) -> Self::Output { 281 | $name(self.0.bitxor(rhs.0)) 282 | } 283 | } 284 | 285 | impl<'a> BitXor<$name> for &'a $name { 286 | type Output = <$name as BitOr<$name>>::Output; 287 | 288 | fn bitxor(self, rhs: $name) -> Self::Output { 289 | $name(self.0.bitxor(rhs.0)) 290 | } 291 | } 292 | 293 | impl<'a> BitXor<&'a $name> for &'a $name { 294 | type Output = <$name as BitOr<$name>>::Output; 295 | 296 | fn bitxor(self, rhs: &'a $name) -> Self::Output { 297 | $name(self.0.bitxor(rhs.0)) 298 | } 299 | } 300 | 301 | impl BitXorAssign<$name> for $name { 302 | fn bitxor_assign(&mut self, other: $name) { 303 | self.0.bitxor_assign(other.0) 304 | } 305 | } 306 | 307 | impl Not for $name { 308 | type Output = $name; 309 | 310 | fn not(self) -> $name { 311 | $name(self.0.not()).mask() 312 | } 313 | } 314 | 315 | impl<'a> Not for &'a $name { 316 | type Output = <$name as Not>::Output; 317 | 318 | fn not(self) -> $name { 319 | $name(self.0.not()).mask() 320 | } 321 | } 322 | 323 | impl BitAnd<$name> for $name { 324 | type Output = $name; 325 | 326 | fn bitand(self, rhs: $name) -> Self::Output { 327 | $name(self.0.bitand(rhs.0)) 328 | } 329 | } 330 | 331 | impl<'a> BitAnd<&'a $name> for $name { 332 | type Output = <$name as BitOr<$name>>::Output; 333 | 334 | fn bitand(self, rhs: &'a $name) -> Self::Output { 335 | $name(self.0.bitand(rhs.0)) 336 | } 337 | } 338 | 339 | impl<'a> BitAnd<$name> for &'a $name { 340 | type Output = <$name as BitOr<$name>>::Output; 341 | 342 | fn bitand(self, rhs: $name) -> Self::Output { 343 | $name(self.0.bitand(rhs.0)) 344 | } 345 | } 346 | 347 | impl<'a> BitAnd<&'a $name> for &'a $name { 348 | type Output = <$name as BitOr<$name>>::Output; 349 | 350 | fn bitand(self, rhs: &'a $name) -> Self::Output { 351 | $name(self.0.bitand(rhs.0)) 352 | } 353 | } 354 | 355 | impl BitAndAssign<$name> for $name { 356 | fn bitand_assign(&mut self, other: $name) { 357 | self.0.bitand_assign(other.0) 358 | } 359 | } 360 | 361 | impl lib::core::ops::Add<$name> for $name { 362 | type Output = $name; 363 | #[allow(unused_comparisons)] 364 | fn add(self, other: $name) -> $name { 365 | if self.0 > 0 && other.0 > 0 { 366 | debug_assert!(Self::MAX.0 - other.0 >= self.0); 367 | } else if self.0 < 0 && other.0 < 0 { 368 | debug_assert!(Self::MIN.0 - other.0 <= self.0); 369 | } 370 | self.wrapping_add(other) 371 | } 372 | } 373 | 374 | impl lib::core::ops::Sub<$name> for $name { 375 | type Output = $name; 376 | #[allow(unused_comparisons)] 377 | fn sub(self, other: $name) -> $name { 378 | if self > other { 379 | debug_assert!(Self::MAX.0 + other.0 >= self.0); 380 | } else if self < other { 381 | debug_assert!(Self::MIN.0 + other.0 <= self.0); 382 | } 383 | self.wrapping_sub(other) 384 | } 385 | } 386 | }; 387 | } 388 | 389 | define_unsigned!(#[doc="The 1-bit unsigned integer type."], u1, 1, u8); 390 | define_unsigned!(#[doc="The 2-bit unsigned integer type."], u2, 2, u8); 391 | define_unsigned!(#[doc="The 3-bit unsigned integer type."], u3, 3, u8); 392 | define_unsigned!(#[doc="The 4-bit unsigned integer type."], u4, 4, u8); 393 | define_unsigned!(#[doc="The 5-bit unsigned integer type."], u5, 5, u8); 394 | define_unsigned!(#[doc="The 6-bit unsigned integer type."], u6, 6, u8); 395 | define_unsigned!(#[doc="The 7-bit unsigned integer type."], u7, 7, u8); 396 | 397 | define_unsigned!(#[doc="The 9-bit unsigned integer type."], u9, 9, u16); 398 | define_unsigned!(#[doc="The 10-bit unsigned integer type."], u10, 10, u16); 399 | define_unsigned!(#[doc="The 11-bit unsigned integer type."], u11, 11, u16); 400 | define_unsigned!(#[doc="The 12-bit unsigned integer type."], u12, 12, u16); 401 | define_unsigned!(#[doc="The 13-bit unsigned integer type."], u13, 13, u16); 402 | define_unsigned!(#[doc="The 14-bit unsigned integer type."], u14, 14, u16); 403 | define_unsigned!(#[doc="The 15-bit unsigned integer type."], u15, 15, u16); 404 | 405 | define_unsigned!(#[doc="The 17-bit unsigned integer type."], u17, 17, u32); 406 | define_unsigned!(#[doc="The 18-bit unsigned integer type."], u18, 18, u32); 407 | define_unsigned!(#[doc="The 19-bit unsigned integer type."], u19, 19, u32); 408 | define_unsigned!(#[doc="The 20-bit unsigned integer type."], u20, 20, u32); 409 | define_unsigned!(#[doc="The 21-bit unsigned integer type."], u21, 21, u32); 410 | define_unsigned!(#[doc="The 22-bit unsigned integer type."], u22, 22, u32); 411 | define_unsigned!(#[doc="The 23-bit unsigned integer type."], u23, 23, u32); 412 | define_unsigned!(#[doc="The 24-bit unsigned integer type."], u24, 24, u32); 413 | 414 | define_unsigned!(#[doc="The 25-bit unsigned integer type."], u25, 25, u32); 415 | define_unsigned!(#[doc="The 26-bit unsigned integer type."], u26, 26, u32); 416 | define_unsigned!(#[doc="The 27-bit unsigned integer type."], u27, 27, u32); 417 | define_unsigned!(#[doc="The 28-bit unsigned integer type."], u28, 28, u32); 418 | define_unsigned!(#[doc="The 29-bit unsigned integer type."], u29, 29, u32); 419 | define_unsigned!(#[doc="The 30-bit unsigned integer type."], u30, 30, u32); 420 | define_unsigned!(#[doc="The 31-bit unsigned integer type."], u31, 31, u32); 421 | 422 | define_unsigned!(#[doc="The 33-bit unsigned integer type."], u33, 33, u64); 423 | define_unsigned!(#[doc="The 34-bit unsigned integer type."], u34, 34, u64); 424 | define_unsigned!(#[doc="The 35-bit unsigned integer type."], u35, 35, u64); 425 | define_unsigned!(#[doc="The 36-bit unsigned integer type."], u36, 36, u64); 426 | define_unsigned!(#[doc="The 37-bit unsigned integer type."], u37, 37, u64); 427 | define_unsigned!(#[doc="The 38-bit unsigned integer type."], u38, 38, u64); 428 | define_unsigned!(#[doc="The 39-bit unsigned integer type."], u39, 39, u64); 429 | define_unsigned!(#[doc="The 40-bit unsigned integer type."], u40, 40, u64); 430 | 431 | define_unsigned!(#[doc="The 41-bit unsigned integer type."], u41, 41, u64); 432 | define_unsigned!(#[doc="The 42-bit unsigned integer type."], u42, 42, u64); 433 | define_unsigned!(#[doc="The 43-bit unsigned integer type."], u43, 43, u64); 434 | define_unsigned!(#[doc="The 44-bit unsigned integer type."], u44, 44, u64); 435 | define_unsigned!(#[doc="The 45-bit unsigned integer type."], u45, 45, u64); 436 | define_unsigned!(#[doc="The 46-bit unsigned integer type."], u46, 46, u64); 437 | define_unsigned!(#[doc="The 47-bit unsigned integer type."], u47, 47, u64); 438 | define_unsigned!(#[doc="The 48-bit unsigned integer type."], u48, 48, u64); 439 | 440 | define_unsigned!(#[doc="The 49-bit unsigned integer type."], u49, 49, u64); 441 | define_unsigned!(#[doc="The 50-bit unsigned integer type."], u50, 50, u64); 442 | define_unsigned!(#[doc="The 51-bit unsigned integer type."], u51, 51, u64); 443 | define_unsigned!(#[doc="The 52-bit unsigned integer type."], u52, 52, u64); 444 | define_unsigned!(#[doc="The 53-bit unsigned integer type."], u53, 53, u64); 445 | define_unsigned!(#[doc="The 54-bit unsigned integer type."], u54, 54, u64); 446 | define_unsigned!(#[doc="The 55-bit unsigned integer type."], u55, 55, u64); 447 | define_unsigned!(#[doc="The 56-bit unsigned integer type."], u56, 56, u64); 448 | 449 | define_unsigned!(#[doc="The 57-bit unsigned integer type."], u57, 57, u64); 450 | define_unsigned!(#[doc="The 58-bit unsigned integer type."], u58, 58, u64); 451 | define_unsigned!(#[doc="The 59-bit unsigned integer type."], u59, 59, u64); 452 | define_unsigned!(#[doc="The 60-bit unsigned integer type."], u60, 60, u64); 453 | define_unsigned!(#[doc="The 61-bit unsigned integer type."], u61, 61, u64); 454 | define_unsigned!(#[doc="The 62-bit unsigned integer type."], u62, 62, u64); 455 | define_unsigned!(#[doc="The 63-bit unsigned integer type."], u63, 63, u64); 456 | 457 | define_unsigned!(#[doc="The 65-bit unsigned integer type."], u65, 65, u128); 458 | define_unsigned!(#[doc="The 66-bit unsigned integer type."], u66, 66, u128); 459 | define_unsigned!(#[doc="The 67-bit unsigned integer type."], u67, 67, u128); 460 | define_unsigned!(#[doc="The 68-bit unsigned integer type."], u68, 68, u128); 461 | define_unsigned!(#[doc="The 69-bit unsigned integer type."], u69, 69, u128); 462 | define_unsigned!(#[doc="The 70-bit unsigned integer type."], u70, 70, u128); 463 | define_unsigned!(#[doc="The 71-bit unsigned integer type."], u71, 71, u128); 464 | define_unsigned!(#[doc="The 72-bit unsigned integer type."], u72, 72, u128); 465 | 466 | define_unsigned!(#[doc="The 73-bit unsigned integer type."], u73, 73, u128); 467 | define_unsigned!(#[doc="The 74-bit unsigned integer type."], u74, 74, u128); 468 | define_unsigned!(#[doc="The 75-bit unsigned integer type."], u75, 75, u128); 469 | define_unsigned!(#[doc="The 76-bit unsigned integer type."], u76, 76, u128); 470 | define_unsigned!(#[doc="The 77-bit unsigned integer type."], u77, 77, u128); 471 | define_unsigned!(#[doc="The 78-bit unsigned integer type."], u78, 78, u128); 472 | define_unsigned!(#[doc="The 79-bit unsigned integer type."], u79, 79, u128); 473 | define_unsigned!(#[doc="The 80-bit unsigned integer type."], u80, 80, u128); 474 | 475 | define_unsigned!(#[doc="The 81-bit unsigned integer type."], u81, 81, u128); 476 | define_unsigned!(#[doc="The 82-bit unsigned integer type."], u82, 82, u128); 477 | define_unsigned!(#[doc="The 83-bit unsigned integer type."], u83, 83, u128); 478 | define_unsigned!(#[doc="The 84-bit unsigned integer type."], u84, 84, u128); 479 | define_unsigned!(#[doc="The 85-bit unsigned integer type."], u85, 85, u128); 480 | define_unsigned!(#[doc="The 86-bit unsigned integer type."], u86, 86, u128); 481 | define_unsigned!(#[doc="The 87-bit unsigned integer type."], u87, 87, u128); 482 | define_unsigned!(#[doc="The 88-bit unsigned integer type."], u88, 88, u128); 483 | 484 | define_unsigned!(#[doc="The 89-bit unsigned integer type."], u89, 89, u128); 485 | define_unsigned!(#[doc="The 90-bit unsigned integer type."], u90, 90, u128); 486 | define_unsigned!(#[doc="The 91-bit unsigned integer type."], u91, 91, u128); 487 | define_unsigned!(#[doc="The 92-bit unsigned integer type."], u92, 92, u128); 488 | define_unsigned!(#[doc="The 93-bit unsigned integer type."], u93, 93, u128); 489 | define_unsigned!(#[doc="The 94-bit unsigned integer type."], u94, 94, u128); 490 | define_unsigned!(#[doc="The 95-bit unsigned integer type."], u95, 95, u128); 491 | define_unsigned!(#[doc="The 96-bit unsigned integer type."], u96, 96, u128); 492 | 493 | define_unsigned!(#[doc="The 97-bit unsigned integer type."], u97, 97, u128); 494 | define_unsigned!(#[doc="The 98-bit unsigned integer type."], u98, 98, u128); 495 | define_unsigned!(#[doc="The 99-bit unsigned integer type."], u99, 99, u128); 496 | define_unsigned!(#[doc="The 100-bit unsigned integer type."], u100, 100, u128); 497 | define_unsigned!(#[doc="The 101-bit unsigned integer type."], u101, 101, u128); 498 | define_unsigned!(#[doc="The 102-bit unsigned integer type."], u102, 102, u128); 499 | define_unsigned!(#[doc="The 103-bit unsigned integer type."], u103, 103, u128); 500 | define_unsigned!(#[doc="The 104-bit unsigned integer type."], u104, 104, u128); 501 | 502 | define_unsigned!(#[doc="The 105-bit unsigned integer type."], u105, 105, u128); 503 | define_unsigned!(#[doc="The 106-bit unsigned integer type."], u106, 106, u128); 504 | define_unsigned!(#[doc="The 107-bit unsigned integer type."], u107, 107, u128); 505 | define_unsigned!(#[doc="The 108-bit unsigned integer type."], u108, 108, u128); 506 | define_unsigned!(#[doc="The 109-bit unsigned integer type."], u109, 109, u128); 507 | define_unsigned!(#[doc="The 110-bit unsigned integer type."], u110, 110, u128); 508 | define_unsigned!(#[doc="The 111-bit unsigned integer type."], u111, 111, u128); 509 | define_unsigned!(#[doc="The 112-bit unsigned integer type."], u112, 112, u128); 510 | 511 | define_unsigned!(#[doc="The 113-bit unsigned integer type."], u113, 113, u128); 512 | define_unsigned!(#[doc="The 114-bit unsigned integer type."], u114, 114, u128); 513 | define_unsigned!(#[doc="The 115-bit unsigned integer type."], u115, 115, u128); 514 | define_unsigned!(#[doc="The 116-bit unsigned integer type."], u116, 116, u128); 515 | define_unsigned!(#[doc="The 117-bit unsigned integer type."], u117, 117, u128); 516 | define_unsigned!(#[doc="The 118-bit unsigned integer type."], u118, 118, u128); 517 | define_unsigned!(#[doc="The 119-bit unsigned integer type."], u119, 119, u128); 518 | define_unsigned!(#[doc="The 120-bit unsigned integer type."], u120, 120, u128); 519 | 520 | define_unsigned!(#[doc="The 121-bit unsigned integer type."], u121, 121, u128); 521 | define_unsigned!(#[doc="The 122-bit unsigned integer type."], u122, 122, u128); 522 | define_unsigned!(#[doc="The 123-bit unsigned integer type."], u123, 123, u128); 523 | define_unsigned!(#[doc="The 124-bit unsigned integer type."], u124, 124, u128); 524 | define_unsigned!(#[doc="The 125-bit unsigned integer type."], u125, 125, u128); 525 | define_unsigned!(#[doc="The 126-bit unsigned integer type."], u126, 126, u128); 526 | define_unsigned!(#[doc="The 127-bit unsigned integer type."], u127, 127, u128); 527 | 528 | define_signed!(#[doc="The 1-bit signed integer type."], i1, 1, i8); 529 | define_signed!(#[doc="The 2-bit signed integer type."], i2, 2, i8); 530 | define_signed!(#[doc="The 3-bit signed integer type."], i3, 3, i8); 531 | define_signed!(#[doc="The 4-bit signed integer type."], i4, 4, i8); 532 | define_signed!(#[doc="The 5-bit signed integer type."], i5, 5, i8); 533 | define_signed!(#[doc="The 6-bit signed integer type."], i6, 6, i8); 534 | define_signed!(#[doc="The 7-bit signed integer type."], i7, 7, i8); 535 | 536 | define_signed!(#[doc="The 9-bit signed integer type."], i9, 9, i16); 537 | define_signed!(#[doc="The 10-bit signed integer type."], i10, 10, i16); 538 | define_signed!(#[doc="The 11-bit signed integer type."], i11, 11, i16); 539 | define_signed!(#[doc="The 12-bit signed integer type."], i12, 12, i16); 540 | define_signed!(#[doc="The 13-bit signed integer type."], i13, 13, i16); 541 | define_signed!(#[doc="The 14-bit signed integer type."], i14, 14, i16); 542 | define_signed!(#[doc="The 15-bit signed integer type."], i15, 15, i16); 543 | 544 | define_signed!(#[doc="The 17-bit signed integer type."], i17, 17, i32); 545 | define_signed!(#[doc="The 18-bit signed integer type."], i18, 18, i32); 546 | define_signed!(#[doc="The 19-bit signed integer type."], i19, 19, i32); 547 | define_signed!(#[doc="The 20-bit signed integer type."], i20, 20, i32); 548 | define_signed!(#[doc="The 21-bit signed integer type."], i21, 21, i32); 549 | define_signed!(#[doc="The 22-bit signed integer type."], i22, 22, i32); 550 | define_signed!(#[doc="The 23-bit signed integer type."], i23, 23, i32); 551 | define_signed!(#[doc="The 24-bit signed integer type."], i24, 24, i32); 552 | 553 | define_signed!(#[doc="The 25-bit signed integer type."], i25, 25, i32); 554 | define_signed!(#[doc="The 26-bit signed integer type."], i26, 26, i32); 555 | define_signed!(#[doc="The 27-bit signed integer type."], i27, 27, i32); 556 | define_signed!(#[doc="The 28-bit signed integer type."], i28, 28, i32); 557 | define_signed!(#[doc="The 29-bit signed integer type."], i29, 29, i32); 558 | define_signed!(#[doc="The 30-bit signed integer type."], i30, 30, i32); 559 | define_signed!(#[doc="The 31-bit signed integer type."], i31, 31, i32); 560 | 561 | define_signed!(#[doc="The 33-bit signed integer type."], i33, 33, i64); 562 | define_signed!(#[doc="The 34-bit signed integer type."], i34, 34, i64); 563 | define_signed!(#[doc="The 35-bit signed integer type."], i35, 35, i64); 564 | define_signed!(#[doc="The 36-bit signed integer type."], i36, 36, i64); 565 | define_signed!(#[doc="The 37-bit signed integer type."], i37, 37, i64); 566 | define_signed!(#[doc="The 38-bit signed integer type."], i38, 38, i64); 567 | define_signed!(#[doc="The 39-bit signed integer type."], i39, 39, i64); 568 | define_signed!(#[doc="The 40-bit signed integer type."], i40, 40, i64); 569 | 570 | define_signed!(#[doc="The 41-bit signed integer type."], i41, 41, i64); 571 | define_signed!(#[doc="The 42-bit signed integer type."], i42, 42, i64); 572 | define_signed!(#[doc="The 43-bit signed integer type."], i43, 43, i64); 573 | define_signed!(#[doc="The 44-bit signed integer type."], i44, 44, i64); 574 | define_signed!(#[doc="The 45-bit signed integer type."], i45, 45, i64); 575 | define_signed!(#[doc="The 46-bit signed integer type."], i46, 46, i64); 576 | define_signed!(#[doc="The 47-bit signed integer type."], i47, 47, i64); 577 | define_signed!(#[doc="The 48-bit signed integer type."], i48, 48, i64); 578 | 579 | define_signed!(#[doc="The 49-bit signed integer type."], i49, 49, i64); 580 | define_signed!(#[doc="The 50-bit signed integer type."], i50, 50, i64); 581 | define_signed!(#[doc="The 51-bit signed integer type."], i51, 51, i64); 582 | define_signed!(#[doc="The 52-bit signed integer type."], i52, 52, i64); 583 | define_signed!(#[doc="The 53-bit signed integer type."], i53, 53, i64); 584 | define_signed!(#[doc="The 54-bit signed integer type."], i54, 54, i64); 585 | define_signed!(#[doc="The 55-bit signed integer type."], i55, 55, i64); 586 | define_signed!(#[doc="The 56-bit signed integer type."], i56, 56, i64); 587 | 588 | define_signed!(#[doc="The 57-bit signed integer type."], i57, 57, i64); 589 | define_signed!(#[doc="The 58-bit signed integer type."], i58, 58, i64); 590 | define_signed!(#[doc="The 59-bit signed integer type."], i59, 59, i64); 591 | define_signed!(#[doc="The 60-bit signed integer type."], i60, 60, i64); 592 | define_signed!(#[doc="The 61-bit signed integer type."], i61, 61, i64); 593 | define_signed!(#[doc="The 62-bit signed integer type."], i62, 62, i64); 594 | define_signed!(#[doc="The 63-bit signed integer type."], i63, 63, i64); 595 | 596 | define_signed!(#[doc="The 65-bit signed integer type."], i65, 65, i128); 597 | define_signed!(#[doc="The 66-bit signed integer type."], i66, 66, i128); 598 | define_signed!(#[doc="The 67-bit signed integer type."], i67, 67, i128); 599 | define_signed!(#[doc="The 68-bit signed integer type."], i68, 68, i128); 600 | define_signed!(#[doc="The 69-bit signed integer type."], i69, 69, i128); 601 | define_signed!(#[doc="The 70-bit signed integer type."], i70, 70, i128); 602 | define_signed!(#[doc="The 71-bit signed integer type."], i71, 71, i128); 603 | define_signed!(#[doc="The 72-bit signed integer type."], i72, 72, i128); 604 | 605 | define_signed!(#[doc="The 73-bit signed integer type."], i73, 73, i128); 606 | define_signed!(#[doc="The 74-bit signed integer type."], i74, 74, i128); 607 | define_signed!(#[doc="The 75-bit signed integer type."], i75, 75, i128); 608 | define_signed!(#[doc="The 76-bit signed integer type."], i76, 76, i128); 609 | define_signed!(#[doc="The 77-bit signed integer type."], i77, 77, i128); 610 | define_signed!(#[doc="The 78-bit signed integer type."], i78, 78, i128); 611 | define_signed!(#[doc="The 79-bit signed integer type."], i79, 79, i128); 612 | define_signed!(#[doc="The 80-bit signed integer type."], i80, 80, i128); 613 | 614 | define_signed!(#[doc="The 81-bit signed integer type."], i81, 81, i128); 615 | define_signed!(#[doc="The 82-bit signed integer type."], i82, 82, i128); 616 | define_signed!(#[doc="The 83-bit signed integer type."], i83, 83, i128); 617 | define_signed!(#[doc="The 84-bit signed integer type."], i84, 84, i128); 618 | define_signed!(#[doc="The 85-bit signed integer type."], i85, 85, i128); 619 | define_signed!(#[doc="The 86-bit signed integer type."], i86, 86, i128); 620 | define_signed!(#[doc="The 87-bit signed integer type."], i87, 87, i128); 621 | define_signed!(#[doc="The 88-bit signed integer type."], i88, 88, i128); 622 | 623 | define_signed!(#[doc="The 89-bit signed integer type."], i89, 89, i128); 624 | define_signed!(#[doc="The 90-bit signed integer type."], i90, 90, i128); 625 | define_signed!(#[doc="The 91-bit signed integer type."], i91, 91, i128); 626 | define_signed!(#[doc="The 92-bit signed integer type."], i92, 92, i128); 627 | define_signed!(#[doc="The 93-bit signed integer type."], i93, 93, i128); 628 | define_signed!(#[doc="The 94-bit signed integer type."], i94, 94, i128); 629 | define_signed!(#[doc="The 95-bit signed integer type."], i95, 95, i128); 630 | define_signed!(#[doc="The 96-bit signed integer type."], i96, 96, i128); 631 | 632 | define_signed!(#[doc="The 97-bit signed integer type."], i97, 97, i128); 633 | define_signed!(#[doc="The 98-bit signed integer type."], i98, 98, i128); 634 | define_signed!(#[doc="The 99-bit signed integer type."], i99, 99, i128); 635 | define_signed!(#[doc="The 100-bit signed integer type."], i100, 100, i128); 636 | define_signed!(#[doc="The 101-bit signed integer type."], i101, 101, i128); 637 | define_signed!(#[doc="The 102-bit signed integer type."], i102, 102, i128); 638 | define_signed!(#[doc="The 103-bit signed integer type."], i103, 103, i128); 639 | define_signed!(#[doc="The 104-bit signed integer type."], i104, 104, i128); 640 | 641 | define_signed!(#[doc="The 105-bit signed integer type."], i105, 105, i128); 642 | define_signed!(#[doc="The 106-bit signed integer type."], i106, 106, i128); 643 | define_signed!(#[doc="The 107-bit signed integer type."], i107, 107, i128); 644 | define_signed!(#[doc="The 108-bit signed integer type."], i108, 108, i128); 645 | define_signed!(#[doc="The 109-bit signed integer type."], i109, 109, i128); 646 | define_signed!(#[doc="The 110-bit signed integer type."], i110, 110, i128); 647 | define_signed!(#[doc="The 111-bit signed integer type."], i111, 111, i128); 648 | define_signed!(#[doc="The 112-bit signed integer type."], i112, 112, i128); 649 | 650 | define_signed!(#[doc="The 113-bit signed integer type."], i113, 113, i128); 651 | define_signed!(#[doc="The 114-bit signed integer type."], i114, 114, i128); 652 | define_signed!(#[doc="The 115-bit signed integer type."], i115, 115, i128); 653 | define_signed!(#[doc="The 116-bit signed integer type."], i116, 116, i128); 654 | define_signed!(#[doc="The 117-bit signed integer type."], i117, 117, i128); 655 | define_signed!(#[doc="The 118-bit signed integer type."], i118, 118, i128); 656 | define_signed!(#[doc="The 119-bit signed integer type."], i119, 119, i128); 657 | define_signed!(#[doc="The 120-bit signed integer type."], i120, 120, i128); 658 | 659 | define_signed!(#[doc="The 121-bit signed integer type."], i121, 121, i128); 660 | define_signed!(#[doc="The 122-bit signed integer type."], i122, 122, i128); 661 | define_signed!(#[doc="The 123-bit signed integer type."], i123, 123, i128); 662 | define_signed!(#[doc="The 124-bit signed integer type."], i124, 124, i128); 663 | define_signed!(#[doc="The 125-bit signed integer type."], i125, 125, i128); 664 | define_signed!(#[doc="The 126-bit signed integer type."], i126, 126, i128); 665 | define_signed!(#[doc="The 127-bit signed integer type."], i127, 127, i128); 666 | 667 | #[cfg(test)] 668 | mod tests { 669 | use super::*; 670 | 671 | #[test] 672 | fn test_masking() { 673 | assert_eq!(u4(0b11000110).mask().0, 0b00000110); 674 | assert_eq!(u4(0b00001000).mask().0, 0b00001000); 675 | assert_eq!(u4(0b00001110).mask().0, 0b00001110); 676 | 677 | assert_eq!(i4(0b11000110u8 as i8).mask().0, 0b00000110u8 as i8); 678 | assert_eq!(i4(0b00001000u8 as i8).mask().0, 0b11111000u8 as i8); 679 | assert_eq!(i4(0b00001110u8 as i8).mask().0, 0b11111110u8 as i8); 680 | } 681 | 682 | #[test] 683 | fn min_max_values() { 684 | assert_eq!(u1::MAX, u1(1)); 685 | assert_eq!(u2::MAX, u2(3)); 686 | assert_eq!(u3::MAX, u3(7)); 687 | assert_eq!(u7::MAX, u7(127)); 688 | assert_eq!(u9::MAX, u9(511)); 689 | 690 | assert_eq!(i1::MAX, i1(0)); 691 | assert_eq!(i2::MAX, i2(1)); 692 | assert_eq!(i3::MAX, i3(3)); 693 | assert_eq!(i7::MAX, i7(63)); 694 | assert_eq!(i9::MAX, i9(255)); 695 | 696 | assert_eq!(u1::MIN, u1(0)); 697 | assert_eq!(u2::MIN, u2(0)); 698 | assert_eq!(u3::MIN, u3(0)); 699 | assert_eq!(u7::MIN, u7(0)); 700 | assert_eq!(u9::MIN, u9(0)); 701 | assert_eq!(u127::MIN, u127(0)); 702 | 703 | assert_eq!(i1::MIN, i1(-1)); 704 | assert_eq!(i2::MIN, i2(-2)); 705 | assert_eq!(i3::MIN, i3(-4)); 706 | assert_eq!(i7::MIN, i7(-64)); 707 | assert_eq!(i9::MIN, i9(-256)); 708 | } 709 | 710 | #[test] 711 | fn test_bits_values() { 712 | assert_eq!(u1::BITS, 1); 713 | assert_eq!(i7::BITS, 7); 714 | assert_eq!(u127::BITS, 127); 715 | } 716 | 717 | #[test] 718 | fn test_wrapping_add() { 719 | assert_eq!(u1::MAX.wrapping_add(u1(1)), u1(0)); 720 | assert_eq!(u1::MAX.wrapping_add(u1(0)), u1(1)); 721 | 722 | assert_eq!(u5::MAX.wrapping_add(u5(1)), u5(0)); 723 | assert_eq!(u5::MAX.wrapping_add(u5(4)), u5(3)); 724 | 725 | assert_eq!(u127::MAX.wrapping_add(u127(100)), u127(99)); 726 | assert_eq!(u127::MAX.wrapping_add(u127(1)), u127(0)); 727 | 728 | assert_eq!(i1::MAX.wrapping_add(i1(0)), i1(0)); 729 | assert_eq!(i1::MAX.wrapping_add(i1(-1)), i1(-1)); 730 | 731 | assert_eq!(i7::MAX.wrapping_add(i7(1)), i7::MIN); 732 | assert_eq!(i7::MAX.wrapping_add(i7(4)), i7(-61)); 733 | } 734 | 735 | #[test] 736 | fn test_wrapping_sub() { 737 | assert_eq!(u1::MIN.wrapping_sub(u1(1)), u1(1)); 738 | assert_eq!(u3(1).wrapping_sub(u3(2)), u3::MAX); 739 | } 740 | 741 | #[test] 742 | #[should_panic] 743 | fn test_add_overflow_u5() { 744 | let _s = u5::MAX + u5(1); 745 | } 746 | 747 | #[test] 748 | #[should_panic] 749 | fn test_add_overflow_u127() { 750 | let _s = u127::MAX + u127(1); 751 | } 752 | 753 | #[test] 754 | #[should_panic] 755 | fn test_add_overflow_i96() { 756 | let _s = i96::MAX + i96(100); 757 | } 758 | 759 | #[test] 760 | #[should_panic] 761 | fn test_add_underflow_i96() { 762 | let _s = i96::MIN + i96(-100); 763 | } 764 | 765 | #[test] 766 | #[should_panic] 767 | fn test_add_underflow_i17() { 768 | let _s = i17::MIN + i17(-1); 769 | } 770 | 771 | #[test] 772 | fn test_add() { 773 | assert_eq!(u5(1) + u5(2), u5(3)); 774 | 775 | assert_eq!(i7::MAX + i7::MIN, i7(-1)); 776 | assert_eq!(i7(4) + i7(-3), i7(1)); 777 | assert_eq!(i7(-4) + i7(3), i7(-1)); 778 | assert_eq!(i7(-3) + i7(-20), i7(-23)); 779 | } 780 | 781 | #[test] 782 | #[should_panic] 783 | fn test_sub_overflow_i23() { 784 | let _s = i23::MIN - i23::MAX; 785 | } 786 | 787 | #[test] 788 | #[should_panic] 789 | fn test_sub_underflow_u5() { 790 | let _s = u5::MIN - u5(1); 791 | } 792 | 793 | #[test] 794 | #[should_panic] 795 | fn test_sub_underflow_i5() { 796 | let _s = i5::MIN - i5(1); 797 | } 798 | 799 | #[test] 800 | fn test_sub() { 801 | assert_eq!(u5(1) - u5(1), u5(0)); 802 | assert_eq!(u5(3) - u5(2), u5(1)); 803 | 804 | assert_eq!(i1(-1) - i1(-1), i1(0)); 805 | assert_eq!(i7::MIN - i7::MIN, i7(0)); 806 | assert_eq!(i7(4) - i7(-3), i7(7)); 807 | assert_eq!(i7(-4) - i7(3), i7(-7)); 808 | assert_eq!(i7(-3) - i7(-20), i7(17)); 809 | } 810 | 811 | #[test] 812 | fn test_shr() { 813 | assert_eq!(u5(8) >> 1usize, u5(4)); 814 | assert_eq!(u5(8) >> 1u8, u5(4)); 815 | assert_eq!(u5(8) >> 1u16, u5(4)); 816 | assert_eq!(u5(8) >> 1u32, u5(4)); 817 | assert_eq!(u5(8) >> 1u64, u5(4)); 818 | assert_eq!(u5(8) >> 1isize, u5(4)); 819 | assert_eq!(u5(8) >> 1i8, u5(4)); 820 | assert_eq!(u5(8) >> 1i16, u5(4)); 821 | assert_eq!(u5(8) >> 1i32, u5(4)); 822 | assert_eq!(u5(8) >> 1i64, u5(4)); 823 | 824 | assert_eq!(u5::MAX >> 4, u5(1)); 825 | 826 | assert_eq!(i7(-1) >> 5, i7(-1)); 827 | } 828 | 829 | #[test] 830 | fn test_shl() { 831 | assert_eq!(u5(16) << 1usize, u5(0)); 832 | assert_eq!(u5(16) << 1u8, u5(0)); 833 | assert_eq!(u5(16) << 1u16, u5(0)); 834 | assert_eq!(u5(16) << 1u32, u5(0)); 835 | assert_eq!(u5(16) << 1u64, u5(0)); 836 | assert_eq!(u5(16) << 1isize, u5(0)); 837 | assert_eq!(u5(16) << 1i8, u5(0)); 838 | assert_eq!(u5(16) << 1i16, u5(0)); 839 | assert_eq!(u5(16) << 1i32, u5(0)); 840 | assert_eq!(u5(16) << 1i64, u5(0)); 841 | 842 | assert_eq!(u5::MAX << 4, u5(16)); 843 | 844 | assert_eq!(i5(16) << 1, i5(0)); 845 | assert_eq!(i7(1) << 3, i7(8)); 846 | } 847 | 848 | #[test] 849 | fn test_shr_assign() { 850 | let mut x = u10(512); 851 | x >>= 1usize; 852 | assert_eq!(x, u10(256)); 853 | x >>= 1isize; 854 | assert_eq!(x, u10(128)); 855 | x >>= 1u8; 856 | assert_eq!(x, u10(64)); 857 | x >>= 1i8; 858 | assert_eq!(x, u10(32)); 859 | x >>= 2u64; 860 | assert_eq!(x, u10(8)); 861 | x >>= 3i32; 862 | assert_eq!(x, u10(1)); 863 | } 864 | 865 | #[test] 866 | fn test_shl_assign() { 867 | let mut x = u9(1); 868 | x <<= 3i32; 869 | assert_eq!(x, u9(8)); 870 | x <<= 2u64; 871 | assert_eq!(x, u9(32)); 872 | x <<= 1usize; 873 | assert_eq!(x, u9(64)); 874 | x <<= 1isize; 875 | assert_eq!(x, u9(128)); 876 | x <<= 1u8; 877 | assert_eq!(x, u9(256)); 878 | x <<= 1u8; 879 | assert_eq!(x, u9(0)); 880 | } 881 | 882 | #[test] 883 | fn test_bitor() { 884 | assert_eq!(u9(1) | u9(8), u9(9)); 885 | assert_eq!(&u9(1) | u9(8), u9(9)); 886 | assert_eq!(u9(1) | &u9(8), u9(9)); 887 | assert_eq!(&u9(1) | &u9(8), u9(9)); 888 | } 889 | 890 | #[test] 891 | fn test_bitor_assign() { 892 | let mut x = u12(4); 893 | x |= u12(1); 894 | assert_eq!(x, u12(5)); 895 | x |= u12(128); 896 | assert_eq!(x, u12(133)); 897 | x = u12(1); 898 | x |= u12(127); 899 | assert_eq!(x, u12(127)); 900 | } 901 | 902 | #[test] 903 | fn test_bitxor() { 904 | assert_eq!(u7(0x7F) ^ u7(42), u7(85)); 905 | assert_eq!(&u7(0) ^ u7(42), u7(42)); 906 | assert_eq!(u7(0x10) ^ &u7(0x1), u7(0x11)); 907 | assert_eq!(&u7(11) ^ &u7(1), u7(10)); 908 | } 909 | 910 | #[test] 911 | fn test_bitxor_assign() { 912 | let mut x = u12(4); 913 | x ^= u12(1); 914 | assert_eq!(x, u12(5)); 915 | x ^= u12(128); 916 | assert_eq!(x, u12(133)); 917 | x ^= u12(1); 918 | assert_eq!(x, u12(132)); 919 | x ^= u12(127); 920 | assert_eq!(x, u12(251)); 921 | } 922 | 923 | #[test] 924 | fn test_bitand() { 925 | assert_eq!(i9(-7) & i9(-9), i9::from(-7i8 & -9i8)); 926 | assert_eq!(&i9(-7) & i9(-9), i9::from(&-7i8 & -9i8)); 927 | assert_eq!(i9(-7) & &i9(-9), i9::from(-7i8 & &-9i8)); 928 | assert_eq!(&i9(-7) & &i9(-9), i9::from(&-7i8 & &-9i8)); 929 | 930 | assert_eq!(u9(8) & u9(9), u9(8)); 931 | assert_eq!(&u9(8) & u9(9), u9(8)); 932 | assert_eq!(u9(8) & &u9(9), u9(8)); 933 | assert_eq!(&u9(8) & &u9(9), u9(8)); 934 | } 935 | 936 | #[test] 937 | fn test_bitand_assign() { 938 | let mut x = u12(255); 939 | x &= u12(127); 940 | assert_eq!(x, u12(127)); 941 | x &= u12(7); 942 | assert_eq!(x, u12(7)); 943 | x &= u12(127); 944 | assert_eq!(x, u12(7)); 945 | x &= u12(4); 946 | assert_eq!(x, u12(4)); 947 | } 948 | 949 | #[test] 950 | fn test_not() { 951 | assert_eq!(!u7(42), u7(85)); 952 | assert_eq!(!u7(0x7F), u7(0)); 953 | assert_eq!(!u7(0), u7(0x7F)); 954 | assert_eq!(!u7(56), u7(71)); 955 | } 956 | 957 | #[test] 958 | fn test_match() { 959 | const SEVEN: u7 = u7::new(7); 960 | match u7(7) { 961 | SEVEN => (), 962 | _ => panic!("Pattern matching failed (7 != 7?)"), 963 | } 964 | match u7(42) { 965 | SEVEN => panic!("Pattern matching failed (7 == 42?)"), 966 | _ => (), 967 | } 968 | } 969 | } 970 | --------------------------------------------------------------------------------