diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 01:02:48 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 01:02:48 +0000 |
commit | cc54b2d9a31d739cd8509d719de04d7266f82bbb (patch) | |
tree | 8ae195a806078dddb243dd9857481738fdc27cb7 | |
parent | 57038662745311c211a8484f68314af288c8adc4 (diff) | |
parent | 49a3012dee89afb715c0522baab3c5132d91c53c (diff) | |
download | enumn-android14-mainline-cellbroadcast-release.tar.gz |
Snap for 10447354 from 49a3012dee89afb715c0522baab3c5132d91c53c to mainline-cellbroadcast-releaseaml_cbr_341710000aml_cbr_341610000aml_cbr_341510010aml_cbr_341410010aml_cbr_341311010aml_cbr_341110000aml_cbr_341011000aml_cbr_340914000android14-mainline-cellbroadcast-release
Change-Id: If7016fcad161b9234dbf2e7652d921f4f97af0a9
-rw-r--r-- | .cargo_vcs_info.json | 7 | ||||
-rw-r--r-- | .clippy.toml | 1 | ||||
-rw-r--r-- | .github/FUNDING.yml | 1 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 29 | ||||
-rw-r--r-- | Android.bp | 6 | ||||
-rw-r--r-- | Cargo.toml | 22 | ||||
-rw-r--r-- | Cargo.toml.orig | 10 | ||||
-rw-r--r-- | METADATA | 15 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | TEST_MAPPING | 17 | ||||
-rw-r--r-- | cargo2android.json | 3 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | tests/test.rs | 52 |
13 files changed, 140 insertions, 35 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index ea3dd4d..081b42b 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "30565e34c2a6e9ded85d27350b8a6c1e6207eb2c" - } -} + "sha1": "6024ffd9b8fa3bf2da7da4e286980d93706dfa4b" + }, + "path_in_vcs": "" +}
\ No newline at end of file diff --git a/.clippy.toml b/.clippy.toml new file mode 100644 index 0000000..3d30690 --- /dev/null +++ b/.clippy.toml @@ -0,0 +1 @@ +msrv = "1.31.0" diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..7507077 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: dtolnay diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 385cd8e..bc711bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,12 @@ on: pull_request: schedule: [cron: "40 1 * * *"] +permissions: + contents: read + +env: + RUSTFLAGS: -Dwarnings + jobs: test: name: Rust ${{matrix.rust}} @@ -13,9 +19,30 @@ jobs: fail-fast: false matrix: rust: [nightly, beta, stable, 1.31.0] + timeout-minutes: 45 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} - run: cargo test + + clippy: + name: Clippy + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' + timeout-minutes: 45 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@clippy + - run: cargo clippy -- -Dclippy::all -Dclippy::pedantic + + outdated: + name: Outdated + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' + timeout-minutes: 45 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/install@cargo-outdated + - run: cargo outdated --workspace --exit-code 1 @@ -1,8 +1,6 @@ // This file is generated by cargo2android.py --config cargo2android.json. // Do not modify this file as changes will be overridden on upgrade. - - package { default_applicable_licenses: ["external_rust_crates_enumn_license"], } @@ -43,7 +41,7 @@ rust_proc_macro { name: "libenumn", crate_name: "enumn", cargo_env_compat: true, - cargo_pkg_version: "0.1.3", + cargo_pkg_version: "0.1.6", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ @@ -51,4 +49,6 @@ rust_proc_macro { "libquote", "libsyn", ], + product_available: true, + vendor_available: true, } @@ -3,28 +3,38 @@ # 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 +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# 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" +rust-version = "1.31" name = "enumn" -version = "0.1.3" +version = "0.1.6" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Convert number to enum" documentation = "https://docs.rs/enumn" readme = "README.md" +keywords = [ + "enum", + "integer", +] +categories = [ + "rust-patterns", + "no-std", +] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/enumn" + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [lib] proc-macro = true + [dependencies.proc-macro2] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 938bfe8..a4b1864 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,13 +1,15 @@ [package] name = "enumn" -version = "0.1.3" +version = "0.1.6" authors = ["David Tolnay <dtolnay@gmail.com>"] +categories = ["rust-patterns", "no-std"] +description = "Convert number to enum" +documentation = "https://docs.rs/enumn" edition = "2018" +keywords = ["enum", "integer"] license = "MIT OR Apache-2.0" -description = "Convert number to enum" repository = "https://github.com/dtolnay/enumn" -documentation = "https://docs.rs/enumn" -readme = "README.md" +rust-version = "1.31" [lib] proc-macro = true @@ -1,3 +1,7 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update rust/crates/enumn +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + name: "enumn" description: "Convert number to enum" third_party { @@ -7,14 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/enumn/enumn-0.1.3.crate" + value: "https://static.crates.io/crates/enumn/enumn-0.1.6.crate" } - version: "0.1.3" - # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same. + version: "0.1.6" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 12 - day: 2 + year: 2023 + month: 2 + day: 1 } } @@ -3,8 +3,8 @@ Convert number to enum [<img alt="github" src="https://img.shields.io/badge/github-dtolnay/enumn-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/enumn) [<img alt="crates.io" src="https://img.shields.io/crates/v/enumn.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/enumn) -[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-enumn-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/enumn) -[<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/enumn/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/enumn/actions?query=branch%3Amaster) +[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-enumn-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/enumn) +[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/dtolnay/enumn/ci.yml?branch=master&style=for-the-badge" height="20">](https://github.com/dtolnay/enumn/actions?query=branch%3Amaster) This crate provides a derive macro to generate a function for converting a primitive integer into the corresponding variant of an enum. diff --git a/TEST_MAPPING b/TEST_MAPPING index 1b3d7fd..4521558 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,19 +1,20 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { - "presubmit": [ + "imports": [ { - "name": "ZipFuseTest" + "path": "packages/modules/Virtualization/authfs" }, { - "name": "authfs_device_test_src_lib" - } - ], - "presubmit-rust": [ + "path": "packages/modules/Virtualization/virtualizationmanager" + }, + { + "path": "packages/modules/Virtualization/zipfuse" + }, { - "name": "ZipFuseTest" + "path": "system/keymint/derive" }, { - "name": "authfs_device_test_src_lib" + "path": "system/keymint/hal" } ] } diff --git a/cargo2android.json b/cargo2android.json index 5c18d15..721cc1a 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -5,5 +5,6 @@ ], "dependencies": true, "device": true, - "run": true + "run": true, + "vendor-available": true } @@ -2,7 +2,7 @@ //! //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github //! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust -//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K +//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs //! //! <br> //! @@ -105,6 +105,12 @@ //! //! Here `Letter::n(65)` would return `Some(Letter::A)`. +#![allow( + clippy::missing_panics_doc, + clippy::needless_doctest_main, + clippy::single_match_else +)] + extern crate proc_macro; use proc_macro::TokenStream; diff --git a/tests/test.rs b/tests/test.rs new file mode 100644 index 0000000..3f2daa7 --- /dev/null +++ b/tests/test.rs @@ -0,0 +1,52 @@ +use enumn::N; + +#[derive(Debug, N, PartialEq)] +enum EmptyEnum {} + +#[test] +fn test_empty() { + assert_eq!(EmptyEnum::n(0), None); + assert_eq!(EmptyEnum::n(1), None); + assert_eq!(EmptyEnum::n(-1), None); +} + +#[derive(Debug, N, PartialEq)] +enum SimpleEnum { + Case0, + Case1, +} + +#[test] +fn test_simple() { + assert_eq!(SimpleEnum::n(0), Some(SimpleEnum::Case0)); + assert_eq!(SimpleEnum::n(1), Some(SimpleEnum::Case1)); + assert_eq!(SimpleEnum::n(4), None); + assert_eq!(SimpleEnum::n(-1), None); +} + +#[derive(Debug, N, PartialEq)] +#[repr(u8)] +enum EnumWithRepr { + Case0, +} + +#[test] +fn test_repr() { + assert_eq!(EnumWithRepr::n(0), Some(EnumWithRepr::Case0)); + assert_eq!(EnumWithRepr::n(255), None); +} + +#[derive(Debug, N, PartialEq)] +enum EnumWithDiscriminant { + A = 10, + B, // implicitly 11 + C = -80, +} + +#[test] +fn test_discriminant() { + assert_eq!(EnumWithDiscriminant::n(10), Some(EnumWithDiscriminant::A)); + assert_eq!(EnumWithDiscriminant::n(11), Some(EnumWithDiscriminant::B)); + assert_eq!(EnumWithDiscriminant::n(-80), Some(EnumWithDiscriminant::C)); + assert_eq!(EnumWithDiscriminant::n(12), None); +} |