diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:39:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:39:49 +0000 |
commit | a0aa2307322cd47bbf416810ac0292925e03be87 (patch) | |
tree | 37076262a026c4b48c8a0e84f44ff9187556ca35 /rust/vendor/num_enum | |
parent | Initial commit. (diff) | |
download | suricata-a0aa2307322cd47bbf416810ac0292925e03be87.tar.xz suricata-a0aa2307322cd47bbf416810ac0292925e03be87.zip |
Adding upstream version 1:7.0.3.upstream/1%7.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'rust/vendor/num_enum')
82 files changed, 2281 insertions, 0 deletions
diff --git a/rust/vendor/num_enum/.cargo-checksum.json b/rust/vendor/num_enum/.cargo-checksum.json new file mode 100644 index 0000000..e4f33bd --- /dev/null +++ b/rust/vendor/num_enum/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a94ee72ec847b1dc690756e5901db879a2e48aa3e51474145b94753c8b0e184f","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-BSD":"0be96d891d00e0ae0df75d7f3289b12871c000a1f5ac744f3b570768d4bb277c","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"808954bb7af3a919b66c792ccef12e31b98070e78e2a83cde665d0e485cb1a11","src/lib.rs":"945470cdb3af273f9e7c3a7800acd3b704f8e5062e650d380ddcad1f8801c144","tests/default.rs":"b53160eca69d72bde6f0b696545c4b218710c3e83cf3a03b218daf9397c50477","tests/from_primitive.rs":"cc336ff4f0072ddf42622fe2fd2bb31746a9333a5f834be498d781f165e39e9b","tests/into_primitive.rs":"1e1549846724f4c173c35d7541500ec9fbdb887554a4e31a7b1bbc87cd7c5f7a","tests/renamed_num_enum.rs":"048e7d5d2b0aaf27eea8372873aa9bd8576759ae1fb363fac7ea662f86ab24b2","tests/try_build.rs":"404e41d74f3649c81c7186f12fafb85d9f1f358737d19e58ccb77a72004fa41f","tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.rs":"18ef4be2bd64fe96f07495a998275e987b1e2062e1e13ec51037b6e9caecdd88","tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.stderr":"e265d10a002188c21e474a453e4667369922356eed48ec5928dcad12442cfe26","tests/try_build/compile_fail/alternative_clashes_with_variant.rs":"f74b83e4cea5771c5ced58e88d619d78717d8907b85ef5f93b0dc6e8b2ff1d9a","tests/try_build/compile_fail/alternative_clashes_with_variant.stderr":"674d0ec2f56810eb35c93b2d5a1d3dbe7d4bec7bebed246cdb34a422a7257400","tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.rs":"cbadc1ec15ad48f745b3df5dfc7c611b6a0f7cd952bf7b2922b4454e612891a5","tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.stderr":"c3dcd5d4954a63446fa6618af4da5fe1a0b7f4d72de52141e3a2611ad91ff095","tests/try_build/compile_fail/alternative_exprs.rs":"3e43280d93bdafb25153cebea387e1b7c3bbde64a7d5f01ef6faba1a6b1e3a88","tests/try_build/compile_fail/alternative_exprs.stderr":"de738c1101d63a88f6f0641aa051e3e2ef88a09196e6051b9bc9ca985260bd0b","tests/try_build/compile_fail/catch_all_multiple_fields.rs":"2bc1be42a64216ab5a9b3e1e75f70f6c21c566f1608061017431baa7a8809a2e","tests/try_build/compile_fail/catch_all_multiple_fields.stderr":"c91aa50d65874296162d9fedaf6627aad9029fe7d4ce10e6d17ea8224d684966","tests/try_build/compile_fail/catch_all_non_tuple.rs":"69fa21f801ba8ad6ff50456ed521c864d5d863652a16fb68b7aa7f3a55f846ca","tests/try_build/compile_fail/catch_all_non_tuple.stderr":"b848dbe45d0c25b5a724c6baa9ca9489ab1565551fca5957a29464b64cc50f47","tests/try_build/compile_fail/catch_all_type_mismatch.rs":"0a259706b24ab70c9534e54a575c936d51a91d937ebe7f127bedc0930e548ca7","tests/try_build/compile_fail/catch_all_type_mismatch.stderr":"d6c712192bb2c1220bfc9b2a6fd3b7aaf7b482061e9deb3e32f4991f6f472846","tests/try_build/compile_fail/conflicting_default.rs":"22f877dbfbe9d2eca01f02a18f8bd613d9765ff3f67bf5b7639b87df86149614","tests/try_build/compile_fail/conflicting_default.stderr":"de0b7378529a796de31c72d6c055f15679add8684d3cf0be2c4f2b7c07655f73","tests/try_build/compile_fail/conflicting_derive.rs":"f9d8f6e90713e00e8a1188673822d29e919d9ea11c1dde0750223f3c81467fa7","tests/try_build/compile_fail/conflicting_derive.stderr":"62156bf148e699269893e015e6c4fe1947a9f7997f0f7ee78d58c0010fc833a7","tests/try_build/compile_fail/default_and_catch_all.rs":"7b5a419805e268a1e9a78286568d2c73036593aaf7a36bb416cecfc15b0fbd3b","tests/try_build/compile_fail/default_and_catch_all.stderr":"743a1254ffe08555eb822aa8238770d0460b16eb1db988b445163de12710adcc","tests/try_build/compile_fail/default_and_catch_all_alt.rs":"66a8bd540df4007f5eff77cf12127d93f3084aef2b187bf4489dfef36600a7cc","tests/try_build/compile_fail/default_and_catch_all_alt.stderr":"9ea1418d2b5e24d20e202e107a25395693b164d7d9f98d2bf9260711c15527ad","tests/try_build/compile_fail/default_and_catch_all_same_variant.rs":"79891f3d3413daede3bd72eff91dc829d0b26ecfbcb457c0cab45967262d1ab9","tests/try_build/compile_fail/default_and_catch_all_same_variant.stderr":"2cad1a90151db938d72100b00dad9362ddbaf47fd842df8552a5ff1006bfc58e","tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.rs":"9d1f92365434d6f7d783f97bde44468dadf1365587439e756ccc7a37610ba241","tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.stderr":"a62720a7490353b6c3df916e6e067491c7c5009499bfcb2b1f6d762d63e3570a","tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.rs":"c253b836587b653011f9db2d436f3ed80af6e642ddf2e96036eace507b192b46","tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.stderr":"95825a1a562e44255c12afcb71478abecb41ab72eeda7328fff4878dc5c7a4b9","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.rs":"ea3002c67e89103ef67b070fce67ff35c7395f68ebd92d473dc84e082b1b6b7a","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.stderr":"51fc97bb66585eadb27008d4055566fba36a8bd9a43f15be17b968509383e9d5","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.rs":"de43c27ed1b8b65da19c422303e215bf68d27984325b1bdd8b097016982b1f6f","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.stderr":"508df932d796e4f37249819642beecfb28b17570e4f9012dd447e20677d47359","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.rs":"bcfeca85937ecd486a9c833d69ef942250a326ce414e4cf0be011899a20e4b2c","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.stderr":"d3f124f5a3254fd7a4fa74f3ce71d584a71b361cd45672e2e2d20bc6f822d022","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.rs":"47c910706f765e75183e7e9f78fbfff3620af577a7a25e879b533269b11ec401","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.stderr":"ff01351f68e237623b6cdd2bc955ec6087faa9e52c56c35536d8b0d72f9343b0","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.rs":"b046c3e6a6c983e902275a72c5d94c489b3c62c84e54de4b7be6deee38a6ebba","tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.stderr":"72e14558f1655e3181dcc1910ade4ddbf50dc9c501659a10a390e1637bf04625","tests/try_build/compile_fail/garbage_attribute.rs":"a8646a08f39da4446afa4f4bf04824ed3879a58272b3c3101cfcdd9c10e2aff3","tests/try_build/compile_fail/garbage_attribute.stderr":"bd94438fb24277c46670dfd677fe203ce7ed753ed6d8fe22ee6a1d0f238b9ccc","tests/try_build/compile_fail/missing_default.rs":"1553f559db4f546f59fbf372bf1453bc02b95510cb8d29ee4639f7257fffaedc","tests/try_build/compile_fail/missing_default.stderr":"cab89b8f30c413d03c87c639b7770682df727c6cf7c88ab89a8689d87bb388b0","tests/try_build/compile_fail/missing_repr.rs":"98803e70b384b92506aecf7a48d1ecfc881f9e26bf033a4aee21947831350083","tests/try_build/compile_fail/missing_repr.stderr":"5e442ac3a4ff2f58004000b9049d5760ef2c76814424a0f884475d6e1f35de41","tests/try_build/compile_fail/multiple_catch_all.rs":"63032bdb3788bd09dcc79105cc8a0f367c79a39c75cca8affaa336b4a00b79b1","tests/try_build/compile_fail/multiple_catch_all.stderr":"3f6219a7a61d2947cbe15b5d567ea516e6a40f18dbbb5b362efa10b06bf381d4","tests/try_build/compile_fail/multiple_catch_all_same_variant.rs":"450217f33c0557e28ee153f97b6d08551127d2e7061b36ff8e438a85c26f7d7e","tests/try_build/compile_fail/multiple_catch_all_same_variant.stderr":"b61e5ecc3010040f09170510c5a41c9afa40938020e38f34c0c35b12605b8412","tests/try_build/compile_fail/multiple_defaults.rs":"9da7df9f33ca260e50ae471a832a95f292c447fa9a49c8e2034fc08f23ae3de2","tests/try_build/compile_fail/multiple_defaults.stderr":"feae6ac0f9554229b7b16dcd0812d05ebbcee30c89ec88a9dc10b1191f8f4453","tests/try_build/compile_fail/multiple_defaults_different_kinds.rs":"c149c8ad4ebf56702282ae5f371f868b6d7ddb3059050ed9753e605b3f4516e7","tests/try_build/compile_fail/multiple_defaults_different_kinds.stderr":"2ca5d7e4ce8a4d9bb1f7fd03348a8fa53e17cee6ff69e5de1b3cc1bfdceb1aeb","tests/try_build/compile_fail/multiple_num_enum_defaults.rs":"6129a341e46f41065eccf204d8d341ace72351cbb8bc2598ad7f395825ec45a7","tests/try_build/compile_fail/multiple_num_enum_defaults.stderr":"a397a6e0b18e925fb72c72c0b5fc913cb925cb1b7a8656bb708ed47c5e21ae8f","tests/try_build/compile_fail/repr_c.rs":"cbab431a6525baa0f70d9ed8a2d58d4f57688a906706dfa5042bad3d80308639","tests/try_build/compile_fail/repr_c.stderr":"9f3a35a6efdbd4bae628361e0dc2400523ee94ea8777867f188ec7294a11372d","tests/try_build/compile_fail/unpexpected_alternatives.rs":"41d461d0026df7bd2aef69764a8af79ab67eef1aa3f52ed1fbcbaaeeded93e49","tests/try_build/compile_fail/unpexpected_alternatives.stderr":"b2837080027d72897981963e2d34948b3ac017ed83fbce9745a7098bf2947ddf","tests/try_build/compile_fail/unpexpected_default.rs":"ed780083c7003702a15aba9370987c194fd773f5bb485eccdef97651e71f911b","tests/try_build/compile_fail/unpexpected_default.stderr":"6d9c3c7b41d53513d2b68d91632740b24b309516cbe50e6e1b4df503bf5996cb","tests/try_build/compile_fail/variants_with_fields.rs":"3caf42df983145f29cf2f9e112038aed1ba5c76f09eb76c52074b5758c7f8f62","tests/try_build/compile_fail/variants_with_fields.stderr":"586b8a3fb6f3cab82acc9e7b966d3c0f5d6aa97bab2bb3bbd570b6074e43d976","tests/try_build/pass/default_and_alternatives.rs":"d554668fff375a84838e6e08642c2ac36090565828e88b69d407a211feb817de","tests/try_build/pass/exhaustive_enum_try_from.rs":"7dde59fae6f1b789c89798c7dc45582cbe8d90ed385cb272d855ec82508d20d3","tests/try_build/pass/exhaustive_enum_via_alternatives.rs":"a62b9271bd4022a69d283cd2fc81197d8f43c42663594493e5b3c11cabbdfbf1","tests/try_build/pass/exhaustive_enum_via_default.rs":"4f9f2f0fd2b7af8c877f54225c623c45f62d8c7c1d7e360bd5f27fb09d8da2ad","tests/try_build/pass/features/complex-expressions/alternate_exprs_exhaustive_with_range.rs":"c253b836587b653011f9db2d436f3ed80af6e642ddf2e96036eace507b192b46","tests/try_build/pass/features/complex-expressions/alternate_exprs_non_exhaustive_with_range.rs":"df29fb93155c457e3beae446124c0f9cbd5b4561a7a34f644b26a2d075926231","tests/try_from_primitive.rs":"34bbe2be0f02fe8ba1d8d59da7ca3f66898e6518a2cb1cf0b09f5fed9000b83c","tests/unsafe_from_primitive.rs":"5dcb3e8b3125b302880d41208b318f8a7f98fec3e0592433f2a84c120b2ed0fc"},"package":"1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"}
\ No newline at end of file diff --git a/rust/vendor/num_enum/Cargo.toml b/rust/vendor/num_enum/Cargo.toml new file mode 100644 index 0000000..c8cf973 --- /dev/null +++ b/rust/vendor/num_enum/Cargo.toml @@ -0,0 +1,64 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "num_enum" +version = "0.5.11" +authors = [ + "Daniel Wagner-Hall <dawagner@gmail.com>", + "Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com>", + "Vincent Esche <regexident@gmail.com>", +] +description = "Procedural macros to make inter-operation between primitives and enums easier." +readme = "README.md" +keywords = [ + "enum", + "conversion", + "safe", + "ffi", + "derive", +] +categories = ["rust-patterns"] +license = "BSD-3-Clause OR MIT OR Apache-2.0" +repository = "https://github.com/illicitonion/num_enum" + +[package.metadata.docs.rs] +features = ["external_doc"] + +[dependencies.num_enum_derive] +version = "0.5.11" +default-features = false + +[dev-dependencies.anyhow] +version = "1.0.14" + +[dev-dependencies.rustversion] +version = "1.0.4" + +[dev-dependencies.trybuild] +version = "1.0.49" + +[dev-dependencies.walkdir] +version = "2" + +[features] +complex-expressions = ["num_enum_derive/complex-expressions"] +default = ["std"] +external_doc = [] +std = ["num_enum_derive/std"] + +[badges.maintenance] +status = "passively-maintained" + +[badges.travis-ci] +branch = "master" +repository = "illicitonion/num_enum" diff --git a/rust/vendor/num_enum/LICENSE-APACHE b/rust/vendor/num_enum/LICENSE-APACHE new file mode 100644 index 0000000..1b5ec8b --- /dev/null +++ b/rust/vendor/num_enum/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/rust/vendor/num_enum/LICENSE-BSD b/rust/vendor/num_enum/LICENSE-BSD new file mode 100644 index 0000000..b742e29 --- /dev/null +++ b/rust/vendor/num_enum/LICENSE-BSD @@ -0,0 +1,27 @@ +Copyright (c) 2018, Daniel Wagner-Hall +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of num_enum nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/rust/vendor/num_enum/LICENSE-MIT b/rust/vendor/num_enum/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/rust/vendor/num_enum/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/rust/vendor/num_enum/README.md b/rust/vendor/num_enum/README.md new file mode 100644 index 0000000..902cee7 --- /dev/null +++ b/rust/vendor/num_enum/README.md @@ -0,0 +1,277 @@ +num_enum +======== + +Procedural macros to make inter-operation between primitives and enums easier. +This crate is no_std compatible. + +[![crates.io](https://img.shields.io/crates/v/num_enum.svg)](https://crates.io/crates/num_enum) +[![Documentation](https://docs.rs/num_enum/badge.svg)](https://docs.rs/num_enum) +[![Build Status](https://travis-ci.org/illicitonion/num_enum.svg?branch=master)](https://travis-ci.org/illicitonion/num_enum) + +Turning an enum into a primitive +-------------------------------- + +```rust +use num_enum::IntoPrimitive; + +#[derive(IntoPrimitive)] +#[repr(u8)] +enum Number { + Zero, + One, +} + +fn main() { + let zero: u8 = Number::Zero.into(); + assert_eq!(zero, 0u8); +} +``` + +`num_enum`'s `IntoPrimitive` is more type-safe than using `as`, because `as` will silently truncate - `num_enum` only derives `From` for exactly the discriminant type of the enum. + +Attempting to turn a primitive into an enum with try_from +---------------------------------------------- + +```rust +use num_enum::TryFromPrimitive; +use std::convert::TryFrom; + +#[derive(Debug, Eq, PartialEq, TryFromPrimitive)] +#[repr(u8)] +enum Number { + Zero, + One, +} + +fn main() { + let zero = Number::try_from(0u8); + assert_eq!(zero, Ok(Number::Zero)); + + let three = Number::try_from(3u8); + assert_eq!( + three.unwrap_err().to_string(), + "No discriminant in enum `Number` matches the value `3`", + ); +} +``` + +Variant alternatives +--------------- + +Sometimes a single enum variant might be representable by multiple numeric values. + +The `#[num_enum(alternatives = [..])]` attribute allows you to define additional value alternatives for individual variants. + +(The behavior of `IntoPrimitive` is unaffected by this attribute, it will always return the canonical value.) + +```rust +use num_enum::TryFromPrimitive; +use std::convert::TryFrom; + +#[derive(Debug, Eq, PartialEq, TryFromPrimitive)] +#[repr(u8)] +enum Number { + Zero = 0, + #[num_enum(alternatives = [2])] + OneOrTwo = 1, +} + +fn main() { + let zero = Number::try_from(0u8); + assert_eq!(zero, Ok(Number::Zero)); + + let one = Number::try_from(1u8); + assert_eq!(one, Ok(Number::OneOrTwo)); + + let two = Number::try_from(2u8); + assert_eq!(two, Ok(Number::OneOrTwo)); + + let three = Number::try_from(3u8); + assert_eq!( + three.unwrap_err().to_string(), + "No discriminant in enum `Number` matches the value `3`", + ); +} +``` + +Range expressions are also supported for alternatives, but this requires enabling the `complex-expressions` feature: + +```rust +use num_enum::TryFromPrimitive; +use std::convert::TryFrom; + +#[derive(Debug, Eq, PartialEq, TryFromPrimitive)] +#[repr(u8)] +enum Number { + Zero = 0, + #[num_enum(alternatives = [2..16])] + Some = 1, + #[num_enum(alternatives = [17, 18..=255])] + Many = 16, +} + +fn main() { + let zero = Number::try_from(0u8); + assert_eq!(zero, Ok(Number::Zero)); + + let some = Number::try_from(15u8); + assert_eq!(some, Ok(Number::Some)); + + let many = Number::try_from(255u8); + assert_eq!(many, Ok(Number::Many)); +} +``` + +Default variant +--------------- + +Sometimes it is desirable to have an `Other` variant in an enum that acts as a kind of a wildcard matching all the value not yet covered by other variants. + +The `#[num_enum(default)]` attribute allows you to mark variant as the default. + +(The behavior of `IntoPrimitive` is unaffected by this attribute, it will always return the canonical value.) + +```rust +use num_enum::TryFromPrimitive; +use std::convert::TryFrom; + +#[derive(Debug, Eq, PartialEq, TryFromPrimitive)] +#[repr(u8)] +enum Number { + Zero = 0, + #[num_enum(default)] + NonZero = 1, +} + +fn main() { + let zero = Number::try_from(0u8); + assert_eq!(zero, Ok(Number::Zero)); + + let one = Number::try_from(1u8); + assert_eq!(one, Ok(Number::NonZero)); + + let two = Number::try_from(2u8); + assert_eq!(two, Ok(Number::NonZero)); +} +``` + +Safely turning a primitive into an exhaustive enum with from_primitive +------------------------------------------------------------- + +If your enum has all possible primitive values covered, you can derive `FromPrimitive` for it (which auto-implement stdlib's `From`): + +You can cover all possible values by: +* Having variants for every possible value +* Having a variant marked `#[num_enum(default)]` +* Having a variant marked `#[num_enum(catch_all)]` +* Having `#[num_enum(alternatives = [...])`s covering values not covered by a variant. + +```rust +use num_enum::FromPrimitive; + +#[derive(Debug, Eq, PartialEq, FromPrimitive)] +#[repr(u8)] +enum Number { + Zero, + #[num_enum(default)] + NonZero, +} + +fn main() { + assert_eq!( + Number::Zero, + Number::from(0_u8), + ); + assert_eq!( + Number::NonZero, + Number::from(1_u8), + ); +} +``` + +Catch-all variant +----------------- + +Sometimes it is desirable to have an `Other` variant which holds the otherwise un-matched value as a field. + +The `#[num_enum(catch_all)]` attribute allows you to mark at most one variant for this purpose. The variant it's applied to must be a tuple variant with exactly one field matching the `repr` type. + +```rust +use num_enum::FromPrimitive; +use std::convert::TryFrom; + +#[derive(Debug, Eq, PartialEq, FromPrimitive)] +#[repr(u8)] +enum Number { + Zero = 0, + #[num_enum(catch_all)] + NonZero(u8), +} + +fn main() { + let zero = Number::from(0u8); + assert_eq!(zero, Number::Zero); + + let one = Number::from(1u8); + assert_eq!(one, Number::NonZero(1_u8)); + + let two = Number::from(2u8); + assert_eq!(two, Number::NonZero(2_u8)); +} +``` + +As this is naturally exhaustive, this is only supported for `FromPrimitive`, not also `TryFromPrimitive`. + +Unsafely turning a primitive into an enum with from_unchecked +------------------------------------------------------------- + +If you're really certain a conversion will succeed (and have not made use of `#[num_enum(default)]` or `#[num_enum(alternatives = [..])]` +for any of its variants), and want to avoid a small amount of overhead, you can use unsafe code to do this conversion. +Unless you have data showing that the match statement generated in the `try_from` above is a bottleneck for you, +you should avoid doing this, as the unsafe code has potential to cause serious memory issues in your program. + +```rust +use num_enum::UnsafeFromPrimitive; + +#[derive(Debug, Eq, PartialEq, UnsafeFromPrimitive)] +#[repr(u8)] +enum Number { + Zero, + One, +} + +fn main() { + assert_eq!( + unsafe { Number::from_unchecked(0_u8) }, + Number::Zero, + ); + assert_eq!( + unsafe { Number::from_unchecked(1_u8) }, + Number::One, + ); +} + +unsafe fn undefined_behavior() { + let _ = Number::from_unchecked(2); // 2 is not a valid discriminant! +} +``` + +Optional features +----------------- + +Some enum values may be composed of complex expressions, for example: + +```rust +enum Number { + Zero = (0, 1).0, + One = (0, 1).1, +} +``` + +To cut down on compile time, these are not supported by default, but if you enable the `complex-expressions` +feature of your dependency on `num_enum`, these should start working. + +License +------- + +num_enum may be used under your choice of the BSD 3-clause, Apache 2, or MIT license. diff --git a/rust/vendor/num_enum/src/lib.rs b/rust/vendor/num_enum/src/lib.rs new file mode 100644 index 0000000..e349c52 --- /dev/null +++ b/rust/vendor/num_enum/src/lib.rs @@ -0,0 +1,67 @@ +// Wrap this in two cfg_attrs so that it continues to parse pre-1.54.0. +// See https://github.com/rust-lang/rust/issues/82768 +#![cfg_attr(feature = "external_doc", cfg_attr(all(), doc = include_str!("../README.md")))] +#![cfg_attr( + not(feature = "external_doc"), + doc = "See <https://docs.rs/num_enum> for more info about this crate." +)] +#![cfg_attr(not(feature = "std"), no_std)] + +pub use ::num_enum_derive::{ + Default, FromPrimitive, IntoPrimitive, TryFromPrimitive, UnsafeFromPrimitive, +}; + +use ::core::fmt; + +pub trait FromPrimitive: Sized { + type Primitive: Copy + Eq; + + fn from_primitive(number: Self::Primitive) -> Self; +} + +pub trait TryFromPrimitive: Sized { + type Primitive: Copy + Eq + fmt::Debug; + + const NAME: &'static str; + + fn try_from_primitive(number: Self::Primitive) -> Result<Self, TryFromPrimitiveError<Self>>; +} + +pub struct TryFromPrimitiveError<Enum: TryFromPrimitive> { + pub number: Enum::Primitive, +} + +impl<Enum: TryFromPrimitive> Copy for TryFromPrimitiveError<Enum> {} +impl<Enum: TryFromPrimitive> Clone for TryFromPrimitiveError<Enum> { + fn clone(&self) -> Self { + TryFromPrimitiveError { + number: self.number, + } + } +} +impl<Enum: TryFromPrimitive> Eq for TryFromPrimitiveError<Enum> {} +impl<Enum: TryFromPrimitive> PartialEq for TryFromPrimitiveError<Enum> { + fn eq(&self, other: &Self) -> bool { + self.number == other.number + } +} +impl<Enum: TryFromPrimitive> fmt::Debug for TryFromPrimitiveError<Enum> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("TryFromPrimitiveError") + .field("number", &self.number) + .finish() + } +} +impl<Enum: TryFromPrimitive> fmt::Display for TryFromPrimitiveError<Enum> { + fn fmt(&self, stream: &'_ mut fmt::Formatter<'_>) -> fmt::Result { + write!( + stream, + "No discriminant in enum `{name}` matches the value `{input:?}`", + name = Enum::NAME, + input = self.number, + ) + } +} + +#[cfg(feature = "std")] +impl<Enum: TryFromPrimitive> ::std::error::Error for TryFromPrimitiveError<Enum> {} diff --git a/rust/vendor/num_enum/tests/default.rs b/rust/vendor/num_enum/tests/default.rs new file mode 100644 index 0000000..80e2d89 --- /dev/null +++ b/rust/vendor/num_enum/tests/default.rs @@ -0,0 +1,33 @@ +// Guard against https://github.com/illicitonion/num_enum/issues/27 +mod alloc {} +mod core {} +mod num_enum {} +mod std {} + +#[test] +fn default() { + #[derive(Debug, Eq, PartialEq, ::num_enum::Default)] + #[repr(u8)] + enum Enum { + #[allow(unused)] + Zero = 0, + #[num_enum(default)] + NonZero = 1, + } + + assert_eq!(Enum::NonZero, <Enum as ::core::default::Default>::default()); +} + +#[test] +fn default_standard_default_attribute() { + #[derive(Debug, Eq, PartialEq, ::num_enum::Default)] + #[repr(u8)] + enum Enum { + #[allow(unused)] + Zero = 0, + #[default] + NonZero = 1, + } + + assert_eq!(Enum::NonZero, <Enum as ::core::default::Default>::default()); +} diff --git a/rust/vendor/num_enum/tests/from_primitive.rs b/rust/vendor/num_enum/tests/from_primitive.rs new file mode 100644 index 0000000..1be33fc --- /dev/null +++ b/rust/vendor/num_enum/tests/from_primitive.rs @@ -0,0 +1,144 @@ +use ::std::convert::TryFrom; + +use ::num_enum::{FromPrimitive, TryFromPrimitive}; + +// Guard against https://github.com/illicitonion/num_enum/issues/27 +mod alloc {} +mod core {} +mod num_enum {} +mod std {} + +#[test] +fn has_from_primitive_number_u64() { + #[derive(Debug, Eq, PartialEq, FromPrimitive)] + #[repr(u64)] + enum Enum { + Zero = 0, + #[num_enum(default)] + NonZero = 1, + } + + let zero = Enum::from_primitive(0_u64); + assert_eq!(zero, Enum::Zero); + + let one = Enum::from_primitive(1_u64); + assert_eq!(one, Enum::NonZero); + + let two = Enum::from_primitive(2_u64); + assert_eq!(two, Enum::NonZero); +} + +#[test] +fn has_from_primitive_number() { + #[derive(Debug, Eq, PartialEq, FromPrimitive)] + #[repr(u8)] + enum Enum { + Zero = 0, + #[num_enum(default)] + NonZero = 1, + } + + let zero = Enum::from_primitive(0_u8); + assert_eq!(zero, Enum::Zero); + + let one = Enum::from_primitive(1_u8); + assert_eq!(one, Enum::NonZero); + + let two = Enum::from_primitive(2_u8); + assert_eq!(two, Enum::NonZero); +} + +#[test] +fn has_from_primitive_number_standard_default_attribute() { + #[derive(Debug, Eq, PartialEq, FromPrimitive)] + #[repr(u8)] + enum Enum { + Zero = 0, + #[default] + NonZero = 1, + } + + let zero = Enum::from_primitive(0_u8); + assert_eq!(zero, Enum::Zero); + + let one = Enum::from_primitive(1_u8); + assert_eq!(one, Enum::NonZero); + + let two = Enum::from_primitive(2_u8); + assert_eq!(two, Enum::NonZero); +} + +#[test] +fn from_primitive_number() { + #[derive(Debug, Eq, PartialEq, FromPrimitive)] + #[repr(u8)] + enum Enum { + #[num_enum(default)] + Whatever = 0, + } + + // #[derive(FromPrimitive)] generates implementations for the following traits: + // + // - `FromPrimitive<T>` + // - `From<T>` + // - `TryFromPrimitive<T>` + // - `TryFrom<T>` + let from_primitive = Enum::from_primitive(0_u8); + assert_eq!(from_primitive, Enum::Whatever); + + let from = Enum::from(0_u8); + assert_eq!(from, Enum::Whatever); + + let try_from_primitive = Enum::try_from_primitive(0_u8); + assert_eq!(try_from_primitive, Ok(Enum::Whatever)); + + let try_from = Enum::try_from(0_u8); + assert_eq!(try_from, Ok(Enum::Whatever)); +} + +#[test] +fn from_primitive_number_catch_all() { + #[derive(Debug, Eq, PartialEq, FromPrimitive)] + #[repr(u8)] + enum Enum { + Zero = 0, + #[num_enum(catch_all)] + NonZero(u8), + } + + let zero = Enum::from_primitive(0_u8); + assert_eq!(zero, Enum::Zero); + + let one = Enum::from_primitive(1_u8); + assert_eq!(one, Enum::NonZero(1_u8)); + + let two = Enum::from_primitive(2_u8); + assert_eq!(two, Enum::NonZero(2_u8)); +} + +#[cfg(feature = "complex-expressions")] +#[test] +fn from_primitive_number_with_inclusive_range() { + #[derive(Debug, Eq, PartialEq, FromPrimitive)] + #[repr(u8)] + enum Enum { + Zero = 0, + #[num_enum(alternatives = [2..=255])] + NonZero, + } + + let zero = Enum::from_primitive(0_u8); + assert_eq!(zero, Enum::Zero); + + let one = Enum::from_primitive(1_u8); + assert_eq!(one, Enum::NonZero); + + let two = Enum::from_primitive(2_u8); + assert_eq!(two, Enum::NonZero); + + let three = Enum::from_primitive(3_u8); + assert_eq!(three, Enum::NonZero); + + let twofivefive = Enum::from_primitive(255_u8); + assert_eq!(twofivefive, Enum::NonZero); +} diff --git a/rust/vendor/num_enum/tests/into_primitive.rs b/rust/vendor/num_enum/tests/into_primitive.rs new file mode 100644 index 0000000..a09bf56 --- /dev/null +++ b/rust/vendor/num_enum/tests/into_primitive.rs @@ -0,0 +1,47 @@ +use ::num_enum::IntoPrimitive; + +// Guard against https://github.com/illicitonion/num_enum/issues/27 +mod alloc {} +mod core {} +mod num_enum {} +mod std {} + +#[derive(IntoPrimitive)] +#[repr(u8)] +enum Enum { + Zero, + One, + Two, +} + +#[test] +fn simple() { + let zero: u8 = Enum::Zero.into(); + assert_eq!(zero, 0u8); + + let one: u8 = Enum::One.into(); + assert_eq!(one, 1u8); + + let two: u8 = Enum::Two.into(); + assert_eq!(two, 2u8); +} + +#[test] +fn catch_all() { + #[derive(Debug, Eq, PartialEq, IntoPrimitive)] + #[repr(u8)] + enum Enum { + Zero = 0, + #[num_enum(catch_all)] + NonZero(u8), + } + + let zero: u8 = Enum::Zero.into(); + assert_eq!(zero, 0u8); + + let one: u8 = Enum::NonZero(1u8).into(); + assert_eq!(one, 1u8); + + let two: u8 = Enum::NonZero(2u8).into(); + assert_eq!(two, 2u8); +} diff --git a/rust/vendor/num_enum/tests/renamed_num_enum.rs b/rust/vendor/num_enum/tests/renamed_num_enum.rs new file mode 100644 index 0000000..44784ed --- /dev/null +++ b/rust/vendor/num_enum/tests/renamed_num_enum.rs @@ -0,0 +1,33 @@ +#[test] +fn no_std() { + assert!(::std::process::Command::new("cargo") + .args([ + "run", + "--manifest-path", + concat!( + env!("CARGO_MANIFEST_DIR"), + "/../renamed_num_enum/Cargo.toml", + ), + ]) + .status() + .unwrap() + .success()) +} + +#[test] +fn std() { + assert!(::std::process::Command::new("cargo") + .args([ + "run", + "--manifest-path", + concat!( + env!("CARGO_MANIFEST_DIR"), + "/../renamed_num_enum/Cargo.toml", + ), + "--features", + "std", + ]) + .status() + .unwrap() + .success()) +} diff --git a/rust/vendor/num_enum/tests/try_build.rs b/rust/vendor/num_enum/tests/try_build.rs new file mode 100644 index 0000000..3c771d1 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build.rs @@ -0,0 +1,123 @@ +use std::error::Error; +use std::path::{Path, PathBuf}; +use walkdir::WalkDir; + +#[test] +fn trybuild() { + let directory = PathBuf::from("tests/try_build"); + + let mut _renamer = None; + + let compile_fail_dir = directory.join("compile_fail"); + + // Sometimes error messages change on beta/nightly - allow alternate errors on those. + _renamer = Some(Renamer::rename(compile_fail_dir.clone()).unwrap()); + + let fail = trybuild::TestCases::new(); + fail.compile_fail(compile_fail_dir.join("*.rs")); + add_feature_dirs(&compile_fail_dir, &fail, ExpectedResult::Fail); + + let pass = trybuild::TestCases::new(); + let pass_dir = directory.join("pass"); + pass.pass(pass_dir.join("*.rs")); + add_feature_dirs(&pass_dir, &pass, ExpectedResult::Pass); +} + +enum ExpectedResult { + Pass, + Fail, +} + +fn add_feature_dirs( + parent_dir: &Path, + test_cases: &trybuild::TestCases, + expected_result: ExpectedResult, +) { + let features_dir = parent_dir.join("features"); + let feature_specific_dir = if cfg!(feature = "complex-expressions") { + features_dir.join("complex-expressions") + } else { + features_dir.join("!complex-expressions") + }; + let tests = feature_specific_dir.join("*.rs"); + match expected_result { + ExpectedResult::Pass => test_cases.pass(tests), + ExpectedResult::Fail => test_cases.compile_fail(tests), + } +} + +struct Renamer(Vec<PathBuf>); + +impl Renamer { + const STDERR_EXTENSION: &'static str = "stderr"; + + #[rustversion::all(beta)] + const VERSION_SPECIFIC_EXTENSION: &'static str = "stderr_beta"; + + #[rustversion::all(nightly)] + const VERSION_SPECIFIC_EXTENSION: &'static str = "stderr_nightly"; + + #[rustversion::all(not(beta), not(nightly))] + const VERSION_SPECIFIC_EXTENSION: &'static str = "stderr_doesnotexist"; + + const NON_VERSION_SPECIFIC_BACKUP_EXTENSION: &'static str = + "stderr_non_version_specific_backup"; + + fn rename(dir: PathBuf) -> anyhow::Result<Self> { + let nightly_paths = WalkDir::new(dir) + .max_depth(1) + .into_iter() + .filter_map(|dir_entry| { + let dir_entry = match dir_entry { + Ok(dir_entry) => dir_entry, + Err(err) => return Some(Err(err)), + }; + let path = dir_entry.path(); + if let Some(file_name) = path.file_name() { + if Path::new(file_name).extension() + == Some(Renamer::VERSION_SPECIFIC_EXTENSION.as_ref()) + { + return Some(Ok(path.to_path_buf())); + } + } + None + }) + .collect::<Result<Vec<_>, _>>()?; + // Create early so that if we end up returning an error this gets dropped and undoes any + // already-done renames. + let renamer = Renamer(nightly_paths); + + for nightly_path in &renamer.0 { + std::fs::rename( + nightly_path.with_extension(Renamer::STDERR_EXTENSION), + nightly_path.with_extension(Renamer::NON_VERSION_SPECIFIC_BACKUP_EXTENSION), + )?; + std::fs::rename( + nightly_path.with_extension(Renamer::VERSION_SPECIFIC_EXTENSION), + nightly_path.with_extension(Renamer::STDERR_EXTENSION), + )?; + } + Ok(renamer) + } +} + +impl Drop for Renamer { + fn drop(&mut self) { + for path in &self.0 { + ignore_error(std::fs::rename( + path.with_extension(Renamer::STDERR_EXTENSION), + path.with_extension(Renamer::VERSION_SPECIFIC_EXTENSION), + )); + ignore_error(std::fs::rename( + path.with_extension(Renamer::NON_VERSION_SPECIFIC_BACKUP_EXTENSION), + path.with_extension(Renamer::STDERR_EXTENSION), + )); + } + } +} + +fn ignore_error<T, E: Error>(result: Result<T, E>) { + if let Err(err) = result { + eprintln!("Ignoring error: {}", err); + } +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.rs new file mode 100644 index 0000000..dd703d4 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.rs @@ -0,0 +1,10 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [3,1,4])] + One = 1, + Two = 2, +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.stderr new file mode 100644 index 0000000..1c6259a --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.stderr @@ -0,0 +1,5 @@ +error: '1' in the alternative values is already attributed as the discriminant of this variant + --> tests/try_build/compile_fail/alternative_clashes_with_its_discriminant.rs:5:34 + | +5 | #[num_enum(alternatives = [3,1,4])] + | ^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant.rs new file mode 100644 index 0000000..3146c84 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant.rs @@ -0,0 +1,12 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [2])] + One = 1, + Two = 2, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant.stderr new file mode 100644 index 0000000..d2b1273 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant.stderr @@ -0,0 +1,5 @@ +error: The discriminant '2' collides with a value attributed to a previous variant + --> tests/try_build/compile_fail/alternative_clashes_with_variant.rs:7:5 + | +7 | Two = 2, + | ^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.rs new file mode 100644 index 0000000..f680737 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.rs @@ -0,0 +1,10 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [5,7,0,3])] + One = 1, + Two = 2, +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.stderr new file mode 100644 index 0000000..5602a54 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.stderr @@ -0,0 +1,5 @@ +error: '0' in the alternative values is already attributed to a previous variant + --> tests/try_build/compile_fail/alternative_clashes_with_variant_out_of_order.rs:5:36 + | +5 | #[num_enum(alternatives = [5,7,0,3])] + | ^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_exprs.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_exprs.rs new file mode 100644 index 0000000..046d9c1 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_exprs.rs @@ -0,0 +1,13 @@ +const THREE: u8 = 3; + +#[derive(num_enum::TryFromPrimitive)] +#[repr(i8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [-1, 2, THREE])] + One = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_exprs.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_exprs.stderr new file mode 100644 index 0000000..33540c5 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/alternative_exprs.stderr @@ -0,0 +1,5 @@ +error: Only literals are allowed as num_enum alternate values + --> tests/try_build/compile_fail/alternative_exprs.rs:7:39 + | +7 | #[num_enum(alternatives = [-1, 2, THREE])] + | ^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_multiple_fields.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_multiple_fields.rs new file mode 100644 index 0000000..5237811 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_multiple_fields.rs @@ -0,0 +1,9 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + Zero = 0, + #[num_enum(catch_all)] + NonZero(u8, u8), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_multiple_fields.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_multiple_fields.stderr new file mode 100644 index 0000000..4854f86 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_multiple_fields.stderr @@ -0,0 +1,5 @@ +error: Variant with `catch_all` must be a tuple with exactly 1 field matching the repr type + --> tests/try_build/compile_fail/catch_all_multiple_fields.rs:5:16 + | +5 | #[num_enum(catch_all)] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_non_tuple.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_non_tuple.rs new file mode 100644 index 0000000..08a4e5d --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_non_tuple.rs @@ -0,0 +1,9 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + Zero = 0, + #[num_enum(catch_all)] + NonZero = 1, +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_non_tuple.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_non_tuple.stderr new file mode 100644 index 0000000..41bf02a --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_non_tuple.stderr @@ -0,0 +1,5 @@ +error: Variant with `catch_all` must be a tuple with exactly 1 field matching the repr type + --> tests/try_build/compile_fail/catch_all_non_tuple.rs:5:16 + | +5 | #[num_enum(catch_all)] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_type_mismatch.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_type_mismatch.rs new file mode 100644 index 0000000..d5b91c1 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_type_mismatch.rs @@ -0,0 +1,9 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + Zero = 0, + #[num_enum(catch_all)] + NonZero(i32), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_type_mismatch.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_type_mismatch.stderr new file mode 100644 index 0000000..5d57fcc --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/catch_all_type_mismatch.stderr @@ -0,0 +1,5 @@ +error: Variant with `catch_all` must be a tuple with exactly 1 field matching the repr type + --> tests/try_build/compile_fail/catch_all_type_mismatch.rs:5:16 + | +5 | #[num_enum(catch_all)] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_default.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_default.rs new file mode 100644 index 0000000..79a1aee --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_default.rs @@ -0,0 +1,9 @@ +#[derive(Default, num_enum::Default)] +#[repr(u8)] +enum Number { + #[default] + Zero, +} + +fn main() { +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_default.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_default.stderr new file mode 100644 index 0000000..69b8872 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_default.stderr @@ -0,0 +1,9 @@ +error[E0119]: conflicting implementations of trait `Default` for type `Number` + --> tests/try_build/compile_fail/conflicting_default.rs:1:19 + | +1 | #[derive(Default, num_enum::Default)] + | ------- ^^^^^^^^^^^^^^^^^ conflicting implementation for `Number` + | | + | first implementation here + | + = note: this error originates in the derive macro `num_enum::Default` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_derive.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_derive.rs new file mode 100644 index 0000000..30b9514 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_derive.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::FromPrimitive, num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero, + #[num_enum(default)] + One, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_derive.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_derive.stderr new file mode 100644 index 0000000..679eb06 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/conflicting_derive.stderr @@ -0,0 +1,20 @@ +error[E0119]: conflicting implementations of trait `TryFromPrimitive` for type `Numbers` + --> tests/try_build/compile_fail/conflicting_derive.rs:1:35 + | +1 | #[derive(num_enum::FromPrimitive, num_enum::TryFromPrimitive)] + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Numbers` + | | + | first implementation here + | + = note: this error originates in the derive macro `num_enum::TryFromPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0119]: conflicting implementations of trait `TryFrom<u8>` for type `Numbers` + --> tests/try_build/compile_fail/conflicting_derive.rs:1:35 + | +1 | #[derive(num_enum::FromPrimitive, num_enum::TryFromPrimitive)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl<T, U> TryFrom<U> for T + where U: Into<T>; + = note: this error originates in the derive macro `num_enum::TryFromPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all.rs new file mode 100644 index 0000000..8034dd0 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all.rs @@ -0,0 +1,10 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + #[default] + Zero = 0, + #[num_enum(catch_all)] + NonZero(u8), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all.stderr new file mode 100644 index 0000000..4427013 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all.stderr @@ -0,0 +1,5 @@ +error: Attribute `catch_all` is mutually exclusive with `default` + --> tests/try_build/compile_fail/default_and_catch_all.rs:6:16 + | +6 | #[num_enum(catch_all)] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_alt.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_alt.rs new file mode 100644 index 0000000..071bbe8 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_alt.rs @@ -0,0 +1,10 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + #[num_enum(default)] + Zero = 0, + #[num_enum(catch_all)] + NonZero(u8), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_alt.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_alt.stderr new file mode 100644 index 0000000..2ef1683 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_alt.stderr @@ -0,0 +1,5 @@ +error: Attribute `catch_all` is mutually exclusive with `default` + --> tests/try_build/compile_fail/default_and_catch_all_alt.rs:6:16 + | +6 | #[num_enum(catch_all)] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant.rs new file mode 100644 index 0000000..251785c --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant.rs @@ -0,0 +1,10 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + Zero = 0, + #[num_enum(catch_all)] + #[default] + NonZero(u8), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant.stderr new file mode 100644 index 0000000..21d77c9 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant.stderr @@ -0,0 +1,5 @@ +error: Attribute `default` is mutually exclusive with `catch_all` + --> tests/try_build/compile_fail/default_and_catch_all_same_variant.rs:6:5 + | +6 | #[default] + | ^^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.rs new file mode 100644 index 0000000..cfa884b --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.rs @@ -0,0 +1,10 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + Zero = 0, + #[num_enum(catch_all)] + #[num_enum(default)] + NonZero(u8), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.stderr new file mode 100644 index 0000000..556afd3 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.stderr @@ -0,0 +1,5 @@ +error: Attribute `default` is mutually exclusive with `catch_all` + --> tests/try_build/compile_fail/default_and_catch_all_same_variant_alt.rs:6:16 + | +6 | #[num_enum(default)] + | ^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.rs new file mode 100644 index 0000000..9de1028 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::FromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [2..=255])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.stderr new file mode 100644 index 0000000..a60cc4d --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.stderr @@ -0,0 +1,5 @@ +error: Ranges are only supported as num_enum alternate values if the `complex-expressions` feature of the crate `num_enum` is enabled + --> tests/try_build/compile_fail/features/!complex-expressions/alternate_exprs_with_range.rs:5:5 + | +5 | #[num_enum(alternatives = [2..=255])] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.rs new file mode 100644 index 0000000..bafbfdb --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [..255])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.stderr new file mode 100644 index 0000000..7dc3d59 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.stderr @@ -0,0 +1,5 @@ +error: When ranges are used for alternate values, both bounds most be explicitly specified numeric literals + --> tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_lower_bound.rs:5:32 + | +5 | #[num_enum(alternatives = [..255])] + | ^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.rs new file mode 100644 index 0000000..2bc2854 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [2..])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.stderr new file mode 100644 index 0000000..f458858 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.stderr @@ -0,0 +1,5 @@ +error: When ranges are used for alternate values, both bounds most be explicitly specified numeric literals + --> tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_missing_upper_bound.rs:5:32 + | +5 | #[num_enum(alternatives = [2..])] + | ^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.rs new file mode 100644 index 0000000..a083acb --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.rs @@ -0,0 +1,13 @@ +const TWO: u8 = 2; + +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [TWO..=255])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.stderr new file mode 100644 index 0000000..40249eb --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.stderr @@ -0,0 +1,5 @@ +error: When ranges are used for alternate values, both bounds most be explicitly specified numeric literals + --> tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_lower_bound.rs:7:32 + | +7 | #[num_enum(alternatives = [TWO..=255])] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.rs new file mode 100644 index 0000000..c7b3edc --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.rs @@ -0,0 +1,13 @@ +const TWOFIVEFIVE: u8 = 255; + +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [2..=TWOFIVEFIVE])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.stderr new file mode 100644 index 0000000..78863b6 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.stderr @@ -0,0 +1,5 @@ +error: When ranges are used for alternate values, both bounds most be explicitly specified numeric literals + --> tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_nonlit_upper_bound.rs:7:32 + | +7 | #[num_enum(alternatives = [2..=TWOFIVEFIVE])] + | ^^^^^^^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.rs new file mode 100644 index 0000000..dc17669 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [255..=2])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.stderr new file mode 100644 index 0000000..b933eda --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.stderr @@ -0,0 +1,5 @@ +error: When using ranges for alternate values, upper bound must not be less than lower bound + --> tests/try_build/compile_fail/features/complex-expressions/alternate_exprs_range_swapped_bounds.rs:5:32 + | +5 | #[num_enum(alternatives = [255..=2])] + | ^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/garbage_attribute.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/garbage_attribute.rs new file mode 100644 index 0000000..62b9e59 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/garbage_attribute.rs @@ -0,0 +1,12 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(garbage)] + One = 1, + Two = 2, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/garbage_attribute.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/garbage_attribute.stderr new file mode 100644 index 0000000..fa0a80f --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/garbage_attribute.stderr @@ -0,0 +1,5 @@ +error: Invalid attribute: expected one of: `default`, `catch_all`, `alternatives` + --> $DIR/garbage_attribute.rs:5:5 + | +5 | #[num_enum(garbage)] + | ^^^^^^^^^^^^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/missing_default.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_default.rs new file mode 100644 index 0000000..afe21c1 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_default.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::FromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero, + One, + Two, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/missing_default.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_default.stderr new file mode 100644 index 0000000..12d40e2 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_default.stderr @@ -0,0 +1,7 @@ +error: #[derive(num_enum::FromPrimitive)] requires enum to be exhaustive, or a variant marked with `#[default]`, `#[num_enum(default)]`, or `#[num_enum(catch_all)` + --> $DIR/missing_default.rs:1:10 + | +1 | #[derive(num_enum::FromPrimitive)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the derive macro `num_enum::FromPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/missing_repr.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_repr.rs new file mode 100644 index 0000000..e48a4ab --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_repr.rs @@ -0,0 +1,7 @@ +#[derive(num_enum::IntoPrimitive)] +enum Numbers { + Zero, + One, +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/missing_repr.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_repr.stderr new file mode 100644 index 0000000..6b0c81b --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/missing_repr.stderr @@ -0,0 +1,7 @@ +error: Missing `#[repr({Integer})]` attribute + --> $DIR/missing_repr.rs:1:10 + | +1 | #[derive(num_enum::IntoPrimitive)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the derive macro `num_enum::IntoPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all.rs new file mode 100644 index 0000000..40d6cba --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all.rs @@ -0,0 +1,10 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + #[num_enum(catch_all)] + Zero(u8), + #[num_enum(catch_all)] + NonZero(u8), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all.stderr new file mode 100644 index 0000000..a8da5e5 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all.stderr @@ -0,0 +1,5 @@ +error: Multiple variants marked with `#[num_enum(catch_all)]` + --> tests/try_build/compile_fail/multiple_catch_all.rs:6:16 + | +6 | #[num_enum(catch_all)] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all_same_variant.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all_same_variant.rs new file mode 100644 index 0000000..75bbfd7 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all_same_variant.rs @@ -0,0 +1,10 @@ +#[derive(Debug, Eq, PartialEq, num_enum::FromPrimitive)] +#[repr(u8)] +enum Enum { + Zero = 0, + #[num_enum(catch_all)] + #[num_enum(catch_all)] + NonZero(u8), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all_same_variant.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all_same_variant.stderr new file mode 100644 index 0000000..7ddf7e6 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_catch_all_same_variant.stderr @@ -0,0 +1,5 @@ +error: Multiple variants marked with `#[num_enum(catch_all)]` + --> tests/try_build/compile_fail/multiple_catch_all_same_variant.rs:6:16 + | +6 | #[num_enum(catch_all)] + | ^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults.rs new file mode 100644 index 0000000..9f942d4 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults.rs @@ -0,0 +1,13 @@ +#[derive(num_enum::FromPrimitive, num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero, + #[default] + One, + #[default] + Two, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults.stderr new file mode 100644 index 0000000..68e6add --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults.stderr @@ -0,0 +1,5 @@ +error: Multiple variants marked `#[default]` or `#[num_enum(default)]` found + --> $DIR/multiple_defaults.rs:7:5 + | +7 | #[default] + | ^^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults_different_kinds.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults_different_kinds.rs new file mode 100644 index 0000000..d1ecef2 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults_different_kinds.rs @@ -0,0 +1,13 @@ +#[derive(num_enum::FromPrimitive, num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero, + #[default] + One, + #[num_enum(default)] + Two, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults_different_kinds.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults_different_kinds.stderr new file mode 100644 index 0000000..4e209ae --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_defaults_different_kinds.stderr @@ -0,0 +1,5 @@ +error: Multiple variants marked `#[default]` or `#[num_enum(default)]` found + --> $DIR/multiple_defaults_different_kinds.rs:7:16 + | +7 | #[num_enum(default)] + | ^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_num_enum_defaults.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_num_enum_defaults.rs new file mode 100644 index 0000000..f8a24e6 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_num_enum_defaults.rs @@ -0,0 +1,13 @@ +#[derive(num_enum::FromPrimitive, num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero, + #[num_enum(default)] + One, + #[num_enum(default)] + Two, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_num_enum_defaults.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_num_enum_defaults.stderr new file mode 100644 index 0000000..f481ee2 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/multiple_num_enum_defaults.stderr @@ -0,0 +1,5 @@ +error: Multiple variants marked `#[default]` or `#[num_enum(default)]` found + --> $DIR/multiple_num_enum_defaults.rs:7:16 + | +7 | #[num_enum(default)] + | ^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/repr_c.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/repr_c.rs new file mode 100644 index 0000000..70deb70 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/repr_c.rs @@ -0,0 +1,8 @@ +#[derive(num_enum::IntoPrimitive)] +#[repr(C)] +enum Numbers { + Zero, + One, +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/repr_c.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/repr_c.stderr new file mode 100644 index 0000000..fb29b12 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/repr_c.stderr @@ -0,0 +1,5 @@ +error: repr(C) doesn't have a well defined size + --> $DIR/repr_c.rs:2:8 + | +2 | #[repr(C)] + | ^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_alternatives.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_alternatives.rs new file mode 100644 index 0000000..4dbdabb --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_alternatives.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::UnsafeFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero, + #[num_enum(alternatives = [2])] + One, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_alternatives.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_alternatives.stderr new file mode 100644 index 0000000..7aac45c --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_alternatives.stderr @@ -0,0 +1,5 @@ +error: #[derive(UnsafeFromPrimitive)] does not support `#[num_enum(alternatives = [..])]` + --> $DIR/unpexpected_alternatives.rs:5:16 + | +5 | #[num_enum(alternatives = [2])] + | ^^^^^^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_default.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_default.rs new file mode 100644 index 0000000..ffb1a0e --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_default.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::UnsafeFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero, + #[num_enum(default)] + NoneZero, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_default.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_default.stderr new file mode 100644 index 0000000..c4127cb --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/unpexpected_default.stderr @@ -0,0 +1,5 @@ +error: #[derive(UnsafeFromPrimitive)] does not support `#[num_enum(default)]` + --> $DIR/unpexpected_default.rs:5:16 + | +5 | #[num_enum(default)] + | ^^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/variants_with_fields.rs b/rust/vendor/num_enum/tests/try_build/compile_fail/variants_with_fields.rs new file mode 100644 index 0000000..6dd548e --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/variants_with_fields.rs @@ -0,0 +1,22 @@ +use num_enum::{FromPrimitive, IntoPrimitive, TryFromPrimitive}; + +#[derive(Debug, Eq, PartialEq, TryFromPrimitive)] +#[repr(u8)] +enum Number { + Zero, + NonZero(u8), +} + +#[derive(Debug, Eq, PartialEq, FromPrimitive)] +#[repr(u8)] +enum Colour { + Red { intensity: u8 }, +} + +#[derive(Debug, Eq, PartialEq, IntoPrimitive)] +#[repr(u8)] +enum Meaningless { + Beep(), +} + +fn main() {} diff --git a/rust/vendor/num_enum/tests/try_build/compile_fail/variants_with_fields.stderr b/rust/vendor/num_enum/tests/try_build/compile_fail/variants_with_fields.stderr new file mode 100644 index 0000000..093cc90 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/compile_fail/variants_with_fields.stderr @@ -0,0 +1,17 @@ +error: `num_enum` only supports unit variants (with no associated data), but `Number::NonZero` was not a unit variant. + --> $DIR/variants_with_fields.rs:7:5 + | +7 | NonZero(u8), + | ^^^^^^^^^^^ + +error: `num_enum` only supports unit variants (with no associated data), but `Colour::Red` was not a unit variant. + --> $DIR/variants_with_fields.rs:13:5 + | +13 | Red { intensity: u8 }, + | ^^^^^^^^^^^^^^^^^^^^^ + +error: `num_enum` only supports unit variants (with no associated data), but `Meaningless::Beep` was not a unit variant. + --> $DIR/variants_with_fields.rs:19:5 + | +19 | Beep(), + | ^^^^^^ diff --git a/rust/vendor/num_enum/tests/try_build/pass/default_and_alternatives.rs b/rust/vendor/num_enum/tests/try_build/pass/default_and_alternatives.rs new file mode 100644 index 0000000..aec5ed3 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/pass/default_and_alternatives.rs @@ -0,0 +1,66 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Default { + #[num_enum(default)] + Foo = 0, + Bar = 1, +} + +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Alternatives { + #[num_enum(alternatives = [])] + Foo = 0, + #[num_enum(alternatives = [3])] + Bar = 1, + #[num_enum(alternatives = [4, 5])] + Baz = 2, + #[num_enum(alternatives = [7])] + #[num_enum(alternatives = [8])] + Blee = 6, +} + +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Both { + #[num_enum(default)] + Foo = 0, + #[num_enum(alternatives = [3])] + Bar = 1, +} + +mod mixed { + #[derive(num_enum::TryFromPrimitive)] + #[repr(u8)] + enum AlternativesFollowedByDefaultInSingleAttribute { + #[num_enum(alternatives = [1, 2], default)] + Foo = 0, + } + + #[derive(num_enum::TryFromPrimitive)] + #[repr(u8)] + enum DefaultFollowedByAlternativesInSingleAttribute { + #[num_enum(default, alternatives = [1, 2])] + Foo = 0, + } + + #[derive(num_enum::TryFromPrimitive)] + #[repr(u8)] + enum AlternativesFollowedByDefaultInMultipleAttributes { + #[num_enum(alternatives = [1, 2])] + #[num_enum(default)] + Foo = 0, + } + + #[derive(num_enum::TryFromPrimitive)] + #[repr(u8)] + enum DefaultFollowedByAlternativesInMultipleAttributes { + #[num_enum(default)] + #[num_enum(alternatives = [1, 2])] + Foo = 0, + } +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_try_from.rs b/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_try_from.rs new file mode 100644 index 0000000..4e9f892 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_try_from.rs @@ -0,0 +1,40 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum ExhaustiveTryFrom { + #[num_enum(alternatives = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])] + A = 0, + #[num_enum(alternatives = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])] + B = 16, + #[num_enum(alternatives = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47])] + C = 32, + #[num_enum(alternatives = [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63])] + D = 48, + #[num_enum(alternatives = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79])] + E = 64, + #[num_enum(alternatives = [81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95])] + F = 80, + #[num_enum(alternatives = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111])] + G = 96, + #[num_enum(alternatives = [113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127])] + H = 112, + #[num_enum(alternatives = [129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143])] + I = 128, + #[num_enum(alternatives = [145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159])] + J = 144, + #[num_enum(alternatives = [161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175])] + K = 160, + #[num_enum(alternatives = [177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191])] + L = 176, + #[num_enum(alternatives = [193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207])] + M = 192, + #[num_enum(alternatives = [209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223])] + N = 208, + #[num_enum(alternatives = [225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239])] + O = 224, + #[num_enum(alternatives = [241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255])] + P = 240, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_via_alternatives.rs b/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_via_alternatives.rs new file mode 100644 index 0000000..c065411 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_via_alternatives.rs @@ -0,0 +1,40 @@ +#[derive(num_enum::FromPrimitive)] +#[repr(u8)] +enum ExhaustiveFrom { + #[num_enum(alternatives = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])] + A = 0, + #[num_enum(alternatives = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])] + B = 16, + #[num_enum(alternatives = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47])] + C = 32, + #[num_enum(alternatives = [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63])] + D = 48, + #[num_enum(alternatives = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79])] + E = 64, + #[num_enum(alternatives = [81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95])] + F = 80, + #[num_enum(alternatives = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111])] + G = 96, + #[num_enum(alternatives = [113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127])] + H = 112, + #[num_enum(alternatives = [129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143])] + I = 128, + #[num_enum(alternatives = [145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159])] + J = 144, + #[num_enum(alternatives = [161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175])] + K = 160, + #[num_enum(alternatives = [177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191])] + L = 176, + #[num_enum(alternatives = [193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207])] + M = 192, + #[num_enum(alternatives = [209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223])] + N = 208, + #[num_enum(alternatives = [225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239])] + O = 224, + #[num_enum(alternatives = [241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255])] + P = 240, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_via_default.rs b/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_via_default.rs new file mode 100644 index 0000000..eb3c357 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/pass/exhaustive_enum_via_default.rs @@ -0,0 +1,39 @@ +#[derive(num_enum::FromPrimitive)] +#[repr(u8)] +enum ExhaustiveFrom { + #[num_enum(default)] + #[num_enum(alternatives = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])] + A = 0, + #[num_enum(alternatives = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])] + B = 16, + #[num_enum(alternatives = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47])] + C = 32, + #[num_enum(alternatives = [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63])] + D = 48, + #[num_enum(alternatives = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79])] + E = 64, + #[num_enum(alternatives = [81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95])] + F = 80, + #[num_enum(alternatives = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111])] + G = 96, + #[num_enum(alternatives = [113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127])] + H = 112, + #[num_enum(alternatives = [129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143])] + I = 128, + #[num_enum(alternatives = [145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159])] + J = 144, + #[num_enum(alternatives = [161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175])] + K = 160, + #[num_enum(alternatives = [177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191])] + L = 176, + #[num_enum(alternatives = [193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207])] + M = 192, + #[num_enum(alternatives = [209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223])] + N = 208, + #[num_enum(alternatives = [225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239])] + O = 224, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/pass/features/complex-expressions/alternate_exprs_exhaustive_with_range.rs b/rust/vendor/num_enum/tests/try_build/pass/features/complex-expressions/alternate_exprs_exhaustive_with_range.rs new file mode 100644 index 0000000..9de1028 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/pass/features/complex-expressions/alternate_exprs_exhaustive_with_range.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::FromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [2..=255])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_build/pass/features/complex-expressions/alternate_exprs_non_exhaustive_with_range.rs b/rust/vendor/num_enum/tests/try_build/pass/features/complex-expressions/alternate_exprs_non_exhaustive_with_range.rs new file mode 100644 index 0000000..0c7dd52 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_build/pass/features/complex-expressions/alternate_exprs_non_exhaustive_with_range.rs @@ -0,0 +1,11 @@ +#[derive(num_enum::TryFromPrimitive)] +#[repr(u8)] +enum Numbers { + Zero = 0, + #[num_enum(alternatives = [2..255])] + NonZero = 1, +} + +fn main() { + +} diff --git a/rust/vendor/num_enum/tests/try_from_primitive.rs b/rust/vendor/num_enum/tests/try_from_primitive.rs new file mode 100644 index 0000000..e6d19f6 --- /dev/null +++ b/rust/vendor/num_enum/tests/try_from_primitive.rs @@ -0,0 +1,504 @@ +use ::std::convert::{TryFrom, TryInto}; + +use ::num_enum::TryFromPrimitive; + +// Guard against https://github.com/illicitonion/num_enum/issues/27 +mod alloc {} +mod core {} +mod num_enum {} +mod std {} + +#[test] +fn simple() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + Zero, + One, + Two, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let three: Result<Enum, _> = 3u8.try_into(); + assert_eq!( + three.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `3`" + ); +} + +#[test] +fn even() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + Zero = 0, + Two = 2, + Four = 4, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!( + one.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `1`" + ); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!(two, Ok(Enum::Two)); + + let three: Result<Enum, _> = 3u8.try_into(); + assert_eq!( + three.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `3`" + ); + + let four: Result<Enum, _> = 4u8.try_into(); + assert_eq!(four, Ok(Enum::Four)); +} + +#[test] +fn skipped_value() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + Zero, + One, + Three = 3, + Four, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!( + two.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `2`" + ); + + let three: Result<Enum, _> = 3u8.try_into(); + assert_eq!(three, Ok(Enum::Three)); + + let four: Result<Enum, _> = 4u8.try_into(); + assert_eq!(four, Ok(Enum::Four)); +} + +#[test] +fn wrong_order() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + Four = 4, + Three = 3, + Zero = 0, + One, // Zero + 1 + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!( + two.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `2`" + ); + + let three: Result<Enum, _> = 3u8.try_into(); + assert_eq!(three, Ok(Enum::Three)); + + let four: Result<Enum, _> = 4u8.try_into(); + assert_eq!(four, Ok(Enum::Four)); +} + +#[test] +fn negative_values() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(i8)] + enum Enum { + MinusTwo = -2, + MinusOne = -1, + Zero = 0, + One = 1, + Two = 2, + } + + let minus_two: Result<Enum, _> = (-2i8).try_into(); + assert_eq!(minus_two, Ok(Enum::MinusTwo)); + + let minus_one: Result<Enum, _> = (-1i8).try_into(); + assert_eq!(minus_one, Ok(Enum::MinusOne)); + + let zero: Result<Enum, _> = 0i8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1i8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2i8.try_into(); + assert_eq!(two, Ok(Enum::Two)); +} + +#[test] +fn discriminant_expressions() { + const ONE: u8 = 1; + + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + Zero, + One = ONE, + Two, + Four = 4u8, + Five, + Six = ONE + ONE + 2u8 + 2, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!(two, Ok(Enum::Two)); + + let three: Result<Enum, _> = 3u8.try_into(); + assert_eq!( + three.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `3`", + ); + + let four: Result<Enum, _> = 4u8.try_into(); + assert_eq!(four, Ok(Enum::Four)); + + let five: Result<Enum, _> = 5u8.try_into(); + assert_eq!(five, Ok(Enum::Five)); + + let six: Result<Enum, _> = 6u8.try_into(); + assert_eq!(six, Ok(Enum::Six)); +} + +#[cfg(feature = "complex-expressions")] +mod complex { + use num_enum::TryFromPrimitive; + use std::convert::TryInto; + + const ONE: u8 = 1; + + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + Zero, + One = ONE, + Two, + Four = 4u8, + Five, + Six = ONE + ONE + 2u8 + 2, + Seven = (7, 2).0, + } + + #[test] + fn different_values() { + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!(two, Ok(Enum::Two)); + + let three: Result<Enum, _> = 3u8.try_into(); + assert_eq!( + three.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `3`", + ); + + let four: Result<Enum, _> = 4u8.try_into(); + assert_eq!(four, Ok(Enum::Four)); + + let five: Result<Enum, _> = 5u8.try_into(); + assert_eq!(five, Ok(Enum::Five)); + + let six: Result<Enum, _> = 6u8.try_into(); + assert_eq!(six, Ok(Enum::Six)); + + let seven: Result<Enum, _> = 7u8.try_into(); + assert_eq!(seven, Ok(Enum::Seven)); + } + + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum EnumWithExclusiveRange { + Zero = 0, + #[num_enum(alternatives = [2..4])] + OneOrTwoOrThree, + } + + #[test] + fn different_values_with_exclusive_range() { + let zero: Result<EnumWithExclusiveRange, _> = 0u8.try_into(); + assert_eq!(zero, Ok(EnumWithExclusiveRange::Zero)); + + let one: Result<EnumWithExclusiveRange, _> = 1u8.try_into(); + assert_eq!(one, Ok(EnumWithExclusiveRange::OneOrTwoOrThree)); + + let two: Result<EnumWithExclusiveRange, _> = 2u8.try_into(); + assert_eq!(two, Ok(EnumWithExclusiveRange::OneOrTwoOrThree)); + + let three: Result<EnumWithExclusiveRange, _> = 3u8.try_into(); + assert_eq!(three, Ok(EnumWithExclusiveRange::OneOrTwoOrThree)); + + let four: Result<EnumWithExclusiveRange, _> = 4u8.try_into(); + assert_eq!( + four.unwrap_err().to_string(), + "No discriminant in enum `EnumWithExclusiveRange` matches the value `4`", + ); + } + + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum EnumWithInclusiveRange { + Zero = 0, + #[num_enum(alternatives = [2..=3])] + OneOrTwoOrThree, + } + + #[test] + fn different_values_with_inclusive_range() { + let zero: Result<EnumWithInclusiveRange, _> = 0u8.try_into(); + assert_eq!(zero, Ok(EnumWithInclusiveRange::Zero)); + + let one: Result<EnumWithInclusiveRange, _> = 1u8.try_into(); + assert_eq!(one, Ok(EnumWithInclusiveRange::OneOrTwoOrThree)); + + let two: Result<EnumWithInclusiveRange, _> = 2u8.try_into(); + assert_eq!(two, Ok(EnumWithInclusiveRange::OneOrTwoOrThree)); + + let three: Result<EnumWithInclusiveRange, _> = 3u8.try_into(); + assert_eq!(three, Ok(EnumWithInclusiveRange::OneOrTwoOrThree)); + + let four: Result<EnumWithInclusiveRange, _> = 4u8.try_into(); + assert_eq!( + four.unwrap_err().to_string(), + "No discriminant in enum `EnumWithInclusiveRange` matches the value `4`", + ); + } +} + +#[test] +fn missing_trailing_comma() { + #[rustfmt::skip] +#[derive(Debug, Eq, PartialEq, TryFromPrimitive)] +#[repr(u8)] +enum Enum { + Zero, + One +} + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!( + two.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `2`" + ); +} + +#[test] +fn ignores_extra_attributes() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[allow(unused)] + #[repr(u8)] + enum Enum { + Zero, + #[allow(unused)] + One, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!( + two.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `2`" + ); +} + +#[test] +fn visibility_is_fine() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + pub(crate) enum Enum { + Zero, + One, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!( + two.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `2`" + ); +} + +#[test] +fn error_variant_is_allowed() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + pub enum Enum { + Ok, + Error, + } + + let ok: Result<Enum, _> = 0u8.try_into(); + assert_eq!(ok, Ok(Enum::Ok)); + + let err: Result<Enum, _> = 1u8.try_into(); + assert_eq!(err, Ok(Enum::Error)); + + let unknown: Result<Enum, _> = 2u8.try_into(); + assert_eq!( + unknown.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `2`" + ); +} + +#[test] +fn alternative_values() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(i8)] + enum Enum { + Zero = 0, + #[num_enum(alternatives = [-1, 2, 3])] + OneTwoThreeOrMinusOne = 1, + } + + let minus_one: Result<Enum, _> = (-1i8).try_into(); + assert_eq!(minus_one, Ok(Enum::OneTwoThreeOrMinusOne)); + + let zero: Result<Enum, _> = 0i8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1i8.try_into(); + assert_eq!(one, Ok(Enum::OneTwoThreeOrMinusOne)); + + let two: Result<Enum, _> = 2i8.try_into(); + assert_eq!(two, Ok(Enum::OneTwoThreeOrMinusOne)); + + let three: Result<Enum, _> = 3i8.try_into(); + assert_eq!(three, Ok(Enum::OneTwoThreeOrMinusOne)); + + let four: Result<Enum, _> = 4i8.try_into(); + assert_eq!( + four.unwrap_err().to_string(), + "No discriminant in enum `Enum` matches the value `4`" + ); +} + +#[test] +fn default_value() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + Zero = 0, + One = 1, + #[num_enum(default)] + Other = 2, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!(two, Ok(Enum::Other)); + + let max_value: Result<Enum, _> = u8::max_value().try_into(); + assert_eq!(max_value, Ok(Enum::Other)); +} + +#[test] +fn alternative_values_and_default_value() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + #[num_enum(default)] + Zero = 0, + One = 1, + #[num_enum(alternatives = [3])] + TwoOrThree = 2, + Four = 4, + } + + let zero: Result<Enum, _> = 0u8.try_into(); + assert_eq!(zero, Ok(Enum::Zero)); + + let one: Result<Enum, _> = 1u8.try_into(); + assert_eq!(one, Ok(Enum::One)); + + let two: Result<Enum, _> = 2u8.try_into(); + assert_eq!(two, Ok(Enum::TwoOrThree)); + + let three: Result<Enum, _> = 3u8.try_into(); + assert_eq!(three, Ok(Enum::TwoOrThree)); + + let four: Result<Enum, _> = 4u8.try_into(); + assert_eq!(four, Ok(Enum::Four)); + + let five: Result<Enum, _> = 5u8.try_into(); + assert_eq!(five, Ok(Enum::Zero)); +} + +#[test] +fn try_from_primitive_number() { + #[derive(Debug, Eq, PartialEq, TryFromPrimitive)] + #[repr(u8)] + enum Enum { + #[num_enum(default)] + Whatever = 0, + } + + // #[derive(FromPrimitive)] generates implementations for the following traits: + // + // - `TryFromPrimitive<T>` + // - `TryFrom<T>` + + let try_from_primitive = Enum::try_from_primitive(0_u8); + assert_eq!(try_from_primitive, Ok(Enum::Whatever)); + + let try_from = Enum::try_from(0_u8); + assert_eq!(try_from, Ok(Enum::Whatever)); +} + +// #[derive(FromPrimitive)] generates implementations for the following traits: +// +// - `FromPrimitive<T>` +// - `From<T>` +// - `TryFromPrimitive<T>` +// - `TryFrom<T>` diff --git a/rust/vendor/num_enum/tests/unsafe_from_primitive.rs b/rust/vendor/num_enum/tests/unsafe_from_primitive.rs new file mode 100644 index 0000000..79fb582 --- /dev/null +++ b/rust/vendor/num_enum/tests/unsafe_from_primitive.rs @@ -0,0 +1,22 @@ +use ::num_enum::UnsafeFromPrimitive; + +// Guard against https://github.com/illicitonion/num_enum/issues/27 +mod alloc {} +mod core {} +mod num_enum {} +mod std {} + +#[test] +fn has_unsafe_from_primitive_number() { + #[derive(Debug, Eq, PartialEq, UnsafeFromPrimitive)] + #[repr(u8)] + enum Enum { + Zero, + One, + } + + unsafe { + assert_eq!(Enum::from_unchecked(0_u8), Enum::Zero); + assert_eq!(Enum::from_unchecked(1_u8), Enum::One); + } +} |