diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:03:13 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-10 07:03:13 +0000 |
commit | 4644729112f3c72236be6eecbad9bc6efb637bdc (patch) | |
tree | 23224284f98ea749c0273ccbb1f1777193b70beb | |
parent | 25a2eb17bef2f1f95e8ccddc503aa4ae5dc6d9f8 (diff) | |
parent | e5c8d7ae5166aafde18d2a1d186ffefda2a3abeb (diff) | |
download | heck-4644729112f3c72236be6eecbad9bc6efb637bdc.tar.gz |
Snap for 8564071 from e5c8d7ae5166aafde18d2a1d186ffefda2a3abeb to mainline-wifi-releaseaml_wif_331910020aml_wif_331810010aml_wif_331710030aml_wif_331613000aml_wif_331511020aml_wif_331414000aml_wif_331310070aml_wif_331112000aml_wif_331016070aml_wif_330910030aml_wif_330810040android13-mainline-wifi-release
Change-Id: I0ecaf4237f8c607f955a77ba2d66ea4788ed4873
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 28 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | Cargo.toml.orig | 3 | ||||
-rw-r--r-- | METADATA | 10 | ||||
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | TEST_MAPPING | 23 | ||||
-rw-r--r-- | cargo2android.json | 5 | ||||
-rw-r--r-- | no_step_on_snek.png | bin | 43512 -> 0 bytes | |||
-rw-r--r-- | src/camel.rs | 2 | ||||
-rw-r--r-- | src/kebab.rs | 2 | ||||
-rw-r--r-- | src/lib.rs | 66 | ||||
-rw-r--r-- | src/mixed.rs | 17 | ||||
-rw-r--r-- | src/shouty_kebab.rs | 2 | ||||
-rw-r--r-- | src/shouty_snake.rs | 7 | ||||
-rw-r--r-- | src/snake.rs | 2 | ||||
-rw-r--r-- | src/title.rs | 2 |
17 files changed, 119 insertions, 70 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index d8c857d..43f6c71 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "1c13e81591e356f13fb97a12d9775876a40c1a02" + "sha1": "d2f9cda3a00a62ae1e0eeeea8f0a081c7598b8c5" } } @@ -1,4 +1,5 @@ -// This file is generated by cargo2android.py --run --device --tests --dependencies. +// 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_heck_license"], @@ -36,38 +37,33 @@ license { ], } -rust_defaults { - name: "heck_defaults", +rust_test { + name: "heck_test_src_lib", + host_supported: true, crate_name: "heck", + cargo_env_compat: true, + cargo_pkg_version: "0.3.3", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, + test_options: { + unit_test: true, + }, edition: "2018", rustlibs: [ "libunicode_segmentation", ], } -rust_test_host { - name: "heck_host_test_src_lib", - defaults: ["heck_defaults"], -} - -rust_test { - name: "heck_device_test_src_lib", - defaults: ["heck_defaults"], -} - rust_library { name: "libheck", host_supported: true, crate_name: "heck", + cargo_env_compat: true, + cargo_pkg_version: "0.3.3", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ "libunicode_segmentation", ], } - -// dependent_library ["feature_list"] -// unicode-segmentation-1.7.1 @@ -13,8 +13,9 @@ [package] edition = "2018" name = "heck" -version = "0.3.2" +version = "0.3.3" authors = ["Without Boats <woboats@gmail.com>"] +include = ["src/**/*", "LICENSE-*", "README.md", "CHANGELOG.md"] description = "heck is a case conversion library." homepage = "https://github.com/withoutboats/heck" documentation = "https://docs.rs/heck" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 13025c2..80acd39 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,7 +1,7 @@ [package] authors = ["Without Boats <woboats@gmail.com>"] name = "heck" -version = "0.3.2" +version = "0.3.3" edition = "2018" license = "MIT OR Apache-2.0" description = "heck is a case conversion library." @@ -10,6 +10,7 @@ repository = "https://github.com/withoutboats/heck" documentation = "https://docs.rs/heck" keywords = ["string", "case", "camel", "snake", "unicode"] readme = "README.md" +include = ["src/**/*", "LICENSE-*", "README.md", "CHANGELOG.md"] [dependencies] unicode-segmentation = "1.2.0" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/heck/heck-0.3.2.crate" + value: "https://static.crates.io/crates/heck/heck-0.3.3.crate" } - version: "0.3.2" + version: "0.3.3" license_type: NOTICE last_upgrade_date { - year: 2020 - month: 12 - day: 22 + year: 2021 + month: 6 + day: 21 } } @@ -1,6 +1,6 @@ # **heck** is a case conversion library -!["I specifically requested the opposite of this."](https://github.com/withoutboats/heck/blob/master/no_step_on_snek.png) +!["I specifically requested the opposite of this."](./no_step_on_snek.png) This library exists to provide case conversion between common cases like CamelCase and snake_case. It is intended to be unicode aware, internally @@ -28,7 +28,7 @@ underscores) are folded into one. ("hello__world" in snake case is therefore "hello_world", not the exact same string). Leading or trailing word boundary indicators are dropped, except insofar as CamelCase capitalizes the first word. -### Cases contained in this library: +## Cases contained in this library: 1. CamelCase 2. snake_case @@ -38,7 +38,7 @@ indicators are dropped, except insofar as CamelCase capitalizes the first word. 6. Title Case 7. SHOUTY-KEBAB-CASE -### Contributing +## Contributing PRs of additional well-established cases welcome. @@ -48,7 +48,14 @@ would prefer **not** to receive PRs to make this behavior more configurable. Bug reports & fixes always welcome. :-) -### License +## MSRV + +The minimum supported Rust version for this crate is 1.32.0. This may change in +minor or patch releases, but we probably won't ever require a very recent +version. If you would like to have a stronger guarantee than that, please open +an issue. + +## License heck is distributed under the terms of both the MIT license and the Apache License (Version 2.0). diff --git a/TEST_MAPPING b/TEST_MAPPING index 60b40b7..e5f5c4c 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,8 +1,27 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by update_crate_tests.py for tests that depend on this crate. { + "imports": [ + { + "path": "external/rust/crates/argh" + }, + { + "path": "external/rust/crates/base64" + } + ], "presubmit": [ { - "name": "heck_device_test_src_lib" + "name": "authfs_device_test_src_lib" + }, + { + "name": "heck_test_src_lib" + } + ], + "presubmit-rust": [ + { + "name": "authfs_device_test_src_lib" + }, + { + "name": "heck_test_src_lib" } ] } diff --git a/cargo2android.json b/cargo2android.json new file mode 100644 index 0000000..d36fb44 --- /dev/null +++ b/cargo2android.json @@ -0,0 +1,5 @@ +{ + "device": true, + "run": true, + "tests": true +}
\ No newline at end of file diff --git a/no_step_on_snek.png b/no_step_on_snek.png Binary files differdeleted file mode 100644 index 8aff445..0000000 --- a/no_step_on_snek.png +++ /dev/null diff --git a/src/camel.rs b/src/camel.rs index fa31f0c..6949435 100644 --- a/src/camel.rs +++ b/src/camel.rs @@ -34,7 +34,7 @@ mod tests { fn $t() { assert_eq!($s1.to_camel_case(), $s2) } - } + }; } t!(test1: "CamelCase" => "CamelCase"); diff --git a/src/kebab.rs b/src/kebab.rs index 94ac322..75e5978 100644 --- a/src/kebab.rs +++ b/src/kebab.rs @@ -33,7 +33,7 @@ mod tests { fn $t() { assert_eq!($s1.to_kebab_case(), $s2) } - } + }; } t!(test1: "CamelCase" => "camel-case"); @@ -7,14 +7,15 @@ //! ## Definition of a word boundary //! //! Word boundaries are defined as the "unicode words" defined in the -//! `unicode_segmentation` library, as well as within those words in this manner: +//! `unicode_segmentation` library, as well as within those words in this +//! manner: //! //! 1. All underscore characters are considered word boundaries. -//! 2. If an uppercase character is followed by lowercase letters, a word boundary -//! is considered to be just prior to that uppercase character. -//! 3. If multiple uppercase characters are consecutive, they are considered to be -//! within a single word, except that the last will be part of the next word if it -//! is followed by lowercase characters (see rule 2). +//! 2. If an uppercase character is followed by lowercase letters, a word +//! boundary is considered to be just prior to that uppercase character. +//! 3. If multiple uppercase characters are consecutive, they are considered to +//! be within a single word, except that the last will be part of the next word +//! if it is followed by lowercase characters (see rule 2). //! //! That is, "HelloWorld" is segmented `Hello|World` whereas "XMLHttpRequest" is //! segmented `XML|Http|Request`. @@ -24,7 +25,8 @@ //! being converted to. Multiple adjacent word boundaries (such as a series of //! underscores) are folded into one. ("hello__world" in snake case is therefore //! "hello_world", not the exact same string). Leading or trailing word boundary -//! indicators are dropped, except insofar as CamelCase capitalizes the first word. +//! indicators are dropped, except insofar as CamelCase capitalizes the first +//! word. //! //! ### Cases contained in this library: //! @@ -58,18 +60,21 @@ use unicode_segmentation::UnicodeSegmentation; fn transform<F, G>(s: &str, with_word: F, boundary: G) -> String where F: Fn(&str, &mut String), - G: Fn(&mut String) + G: Fn(&mut String), { - - /// Tracks the current 'mode' of the transformation algorithm as it scans the input string. + /// Tracks the current 'mode' of the transformation algorithm as it scans + /// the input string. /// - /// The mode is a tri-state which tracks the case of the last cased character of the current - /// word. If there is no cased character (either lowercase or uppercase) since the previous - /// word boundary, than the mode is `Boundary`. If the last cased character is lowercase, then - /// the mode is `Lowercase`. Othertherwise, the mode is `Uppercase`. + /// The mode is a tri-state which tracks the case of the last cased + /// character of the current word. If there is no cased character + /// (either lowercase or uppercase) since the previous word boundary, + /// than the mode is `Boundary`. If the last cased character is lowercase, + /// then the mode is `Lowercase`. Othertherwise, the mode is + /// `Uppercase`. #[derive(Clone, Copy, PartialEq)] enum WordMode { - /// There have been no lowercase or uppercase characters in the current word. + /// There have been no lowercase or uppercase characters in the current + /// word. Boundary, /// The previous cased character in the current word is lowercase. Lowercase, @@ -88,14 +93,15 @@ where while let Some((i, c)) = char_indices.next() { // Skip underscore characters if c == '_' { - if init == i { init += 1; } - continue + if init == i { + init += 1; + } + continue; } if let Some(&(next_i, next)) = char_indices.peek() { - - // The mode including the current character, assuming the current character does - // not result in a word boundary. + // The mode including the current character, assuming the + // current character does not result in a word boundary. let next_mode = if c.is_lowercase() { WordMode::Lowercase } else if c.is_uppercase() { @@ -107,7 +113,9 @@ where // Word boundary after if next is underscore or current is // not uppercase and next is uppercase if next == '_' || (next_mode == WordMode::Lowercase && next.is_uppercase()) { - if !first_word { boundary(&mut out); } + if !first_word { + boundary(&mut out); + } with_word(&word[init..next_i], &mut out); first_word = false; init = next_i; @@ -116,8 +124,11 @@ where // Otherwise if current and previous are uppercase and next // is lowercase, word boundary before } else if mode == WordMode::Uppercase && c.is_uppercase() && next.is_lowercase() { - if !first_word { boundary(&mut out); } - else { first_word = false; } + if !first_word { + boundary(&mut out); + } else { + first_word = false; + } with_word(&word[init..i], &mut out); init = i; mode = WordMode::Boundary; @@ -128,8 +139,11 @@ where } } else { // Collect trailing characters as a word - if !first_word { boundary(&mut out); } - else { first_word = false; } + if !first_word { + boundary(&mut out); + } else { + first_word = false; + } with_word(&word[init..], &mut out); break; } @@ -150,7 +164,7 @@ fn lowercase(s: &str, out: &mut String) { } } -fn uppercase(s: &str, out: &mut String ) { +fn uppercase(s: &str, out: &mut String) { for c in s.chars() { out.extend(c.to_uppercase()) } diff --git a/src/mixed.rs b/src/mixed.rs index cca3262..71089f2 100644 --- a/src/mixed.rs +++ b/src/mixed.rs @@ -20,10 +20,17 @@ pub trait MixedCase: ToOwned { impl MixedCase for str { fn to_mixed_case(&self) -> String { - transform(self, |s, out| { - if out.is_empty() { lowercase(s, out); } - else { capitalize(s, out) } - }, |_| {}) + transform( + self, + |s, out| { + if out.is_empty() { + lowercase(s, out); + } else { + capitalize(s, out) + } + }, + |_| {}, + ) } } @@ -37,7 +44,7 @@ mod tests { fn $t() { assert_eq!($s1.to_mixed_case(), $s2) } - } + }; } t!(test1: "CamelCase" => "camelCase"); diff --git a/src/shouty_kebab.rs b/src/shouty_kebab.rs index 0e0c7e7..0225471 100644 --- a/src/shouty_kebab.rs +++ b/src/shouty_kebab.rs @@ -34,7 +34,7 @@ mod tests { fn $t() { assert_eq!($s1.to_shouty_kebab_case(), $s2) } - } + }; } t!(test1: "CamelCase" => "CAMEL-CASE"); diff --git a/src/shouty_snake.rs b/src/shouty_snake.rs index 43be539..8f4289a 100644 --- a/src/shouty_snake.rs +++ b/src/shouty_snake.rs @@ -18,8 +18,8 @@ pub trait ShoutySnakeCase: ToOwned { fn to_shouty_snake_case(&self) -> Self::Owned; } -/// Oh heck, ShoutySnekCase is an alias for ShoutySnakeCase. See ShoutySnakeCase for -/// more documentation. +/// Oh heck, ShoutySnekCase is an alias for ShoutySnakeCase. See ShoutySnakeCase +/// for more documentation. pub trait ShoutySnekCase: ToOwned { /// CONVERT THIS TYPE TO SNEK CASE. #[allow(non_snake_case)] @@ -32,7 +32,6 @@ impl<T: ?Sized + ShoutySnakeCase> ShoutySnekCase for T { } } - impl ShoutySnakeCase for str { fn to_shouty_snake_case(&self) -> Self::Owned { transform(self, uppercase, |s| s.push('_')) @@ -49,7 +48,7 @@ mod tests { fn $t() { assert_eq!($s1.to_shouty_snake_case(), $s2) } - } + }; } t!(test1: "CamelCase" => "CAMEL_CASE"); diff --git a/src/snake.rs b/src/snake.rs index 13329fe..c1ad376 100644 --- a/src/snake.rs +++ b/src/snake.rs @@ -46,7 +46,7 @@ mod tests { fn $t() { assert_eq!($s1.to_snake_case(), $s2) } - } + }; } t!(test1: "CamelCase" => "camel_case"); diff --git a/src/title.rs b/src/title.rs index 3723f1f..015a9fa 100644 --- a/src/title.rs +++ b/src/title.rs @@ -34,7 +34,7 @@ mod tests { fn $t() { assert_eq!($s1.to_title_case(), $s2) } - } + }; } t!(test1: "CamelCase" => "Camel Case"); |