summaryrefslogtreecommitdiffstats
path: root/vendor/heck
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/heck
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/heck')
-rw-r--r--vendor/heck/.cargo-checksum.json2
-rw-r--r--vendor/heck/CHANGELOG.md6
-rw-r--r--vendor/heck/Cargo.toml18
-rw-r--r--vendor/heck/README.md1
-rw-r--r--vendor/heck/src/lib.rs5
-rw-r--r--vendor/heck/src/train.rs85
6 files changed, 112 insertions, 5 deletions
diff --git a/vendor/heck/.cargo-checksum.json b/vendor/heck/.cargo-checksum.json
index 53489f09e..ffff4c9c2 100644
--- a/vendor/heck/.cargo-checksum.json
+++ b/vendor/heck/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"7d296f025b37feeaf276aa7625a5acda57f114bcf431545de58837052296055f","Cargo.toml":"a18bb2b4734e246fb3aa048726920f343152c60232404775d435ac8c4985fc8c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.md":"9c2cf669f34fdcc10472a4be9fc70cf97a8f7d6a5caced9983f0e05b576d8b11","src/kebab.rs":"f2a4900541fe36584b0705108f5f1d23501bcb3429fffe04106077baecc6dc5a","src/lib.rs":"64d3ef695fc32479cfda997ed17b662eeebac0e34c8b3580bd3d428e878559cf","src/lower_camel.rs":"24a3ea7ce7f765b27fb0adec207498569f27045edc56c9089ae05fc428c54d5f","src/shouty_kebab.rs":"4516fbb2295c400869221912257828c90e7c0d43f3bdf4aaefb6d384606f4866","src/shouty_snake.rs":"01b8c1e7ac5e680827e2744e62bf4704fc7ebd0d555c5b040bca5f5fb50e4ffd","src/snake.rs":"fc69443dd1a9248667484d5feb52911a1c6dfed1442b01b5b23e371c5b716a5e","src/title.rs":"0cc0b3014559ab6047ed9e7afb624bbe97014a4498297a4c3b28f3410b75d1dc","src/upper_camel.rs":"9cb094ade94cf6212a4b6e491b0fdad92ad8fbb0d55095c70691f9d66ce25366"},"package":"2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"} \ No newline at end of file
+{"files":{"CHANGELOG.md":"be2b711f318b4447b7c0fa067ac1804dff0b01894d2782722646910a6b2c4b10","Cargo.toml":"bef2e967708cafccb70a6de0f2eeed8914f9a58c1fc9094cf0e6bde671768f7b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.md":"a53c56a404fa7b97e4a5426798430186e715fcf38480327d42700494cae70f76","src/kebab.rs":"f2a4900541fe36584b0705108f5f1d23501bcb3429fffe04106077baecc6dc5a","src/lib.rs":"6cf5759deb604eb1035061ed52c1f71a629ac3fa6faefecceeb9d3cb9f4a9919","src/lower_camel.rs":"24a3ea7ce7f765b27fb0adec207498569f27045edc56c9089ae05fc428c54d5f","src/shouty_kebab.rs":"4516fbb2295c400869221912257828c90e7c0d43f3bdf4aaefb6d384606f4866","src/shouty_snake.rs":"01b8c1e7ac5e680827e2744e62bf4704fc7ebd0d555c5b040bca5f5fb50e4ffd","src/snake.rs":"fc69443dd1a9248667484d5feb52911a1c6dfed1442b01b5b23e371c5b716a5e","src/title.rs":"0cc0b3014559ab6047ed9e7afb624bbe97014a4498297a4c3b28f3410b75d1dc","src/train.rs":"6d20c7153b2e574653c57d039a5077c707c4f15e5b8be765bd5042a4dabc32d4","src/upper_camel.rs":"9cb094ade94cf6212a4b6e491b0fdad92ad8fbb0d55095c70691f9d66ce25366"},"package":"95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"} \ No newline at end of file
diff --git a/vendor/heck/CHANGELOG.md b/vendor/heck/CHANGELOG.md
index 1e02914a7..c0f2f24de 100644
--- a/vendor/heck/CHANGELOG.md
+++ b/vendor/heck/CHANGELOG.md
@@ -1,3 +1,9 @@
+# 0.4.1
+
+Improvements:
+
+- Add Train-Case support
+
# 0.4.0
Breaking changes:
diff --git a/vendor/heck/Cargo.toml b/vendor/heck/Cargo.toml
index b72cceb1c..799036860 100644
--- a/vendor/heck/Cargo.toml
+++ b/vendor/heck/Cargo.toml
@@ -12,16 +12,28 @@
[package]
edition = "2018"
name = "heck"
-version = "0.4.0"
+version = "0.4.1"
authors = ["Without Boats <woboats@gmail.com>"]
-include = ["src/**/*", "LICENSE-*", "README.md", "CHANGELOG.md"]
+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"
readme = "README.md"
-keywords = ["string", "case", "camel", "snake", "unicode"]
+keywords = [
+ "string",
+ "case",
+ "camel",
+ "snake",
+ "unicode",
+]
license = "MIT OR Apache-2.0"
repository = "https://github.com/withoutboats/heck"
+
[dependencies.unicode-segmentation]
version = "1.2.0"
optional = true
diff --git a/vendor/heck/README.md b/vendor/heck/README.md
index 5099339b9..5e052e759 100644
--- a/vendor/heck/README.md
+++ b/vendor/heck/README.md
@@ -37,6 +37,7 @@ indicators are dropped, except insofar as CamelCase capitalizes the first word.
5. SHOUTY_SNAKE_CASE
6. Title Case
7. SHOUTY-KEBAB-CASE
+8. Train-Case
## Contributing
diff --git a/vendor/heck/src/lib.rs b/vendor/heck/src/lib.rs
index 21a45f0be..49bfb0efd 100644
--- a/vendor/heck/src/lib.rs
+++ b/vendor/heck/src/lib.rs
@@ -1,7 +1,7 @@
//! **heck** is a case conversion library.
//!
//! This library exists to provide case conversion between common cases like
-//! CamelCase and snake_case. It is intended to be unicode aware, internally,
+//! CamelCase and snake_case. It is intended to be unicode aware, internally
//! consistent, and reasonably well performing.
//!
//! ## Definition of a word boundary
@@ -37,6 +37,7 @@
//! 5. SHOUTY_SNAKE_CASE
//! 6. Title Case
//! 7. SHOUTY-KEBAB-CASE
+//! 8. Train-Case
#![deny(missing_docs)]
#![forbid(unsafe_code)]
@@ -46,6 +47,7 @@ mod shouty_kebab;
mod shouty_snake;
mod snake;
mod title;
+mod train;
mod upper_camel;
pub use kebab::{AsKebabCase, ToKebabCase};
@@ -56,6 +58,7 @@ pub use shouty_snake::{
};
pub use snake::{AsSnakeCase, AsSnakeCase as AsSnekCase, ToSnakeCase, ToSnekCase};
pub use title::{AsTitleCase, ToTitleCase};
+pub use train::{AsTrainCase, ToTrainCase};
pub use upper_camel::{
AsUpperCamelCase, AsUpperCamelCase as AsPascalCase, ToPascalCase, ToUpperCamelCase,
};
diff --git a/vendor/heck/src/train.rs b/vendor/heck/src/train.rs
new file mode 100644
index 000000000..04dd6a996
--- /dev/null
+++ b/vendor/heck/src/train.rs
@@ -0,0 +1,85 @@
+use std::fmt;
+
+use crate::{capitalize, transform};
+
+/// This trait defines a train case conversion.
+///
+/// In Train-Case, word boundaries are indicated by hyphens and words start
+/// with Capital Letters.
+///
+/// ## Example:
+///
+/// ```rust
+/// use heck::ToTrainCase;
+///
+/// let sentence = "We are going to inherit the earth.";
+/// assert_eq!(sentence.to_train_case(), "We-Are-Going-To-Inherit-The-Earth");
+/// ```
+pub trait ToTrainCase: ToOwned {
+ /// Convert this type to Train-Case.
+ fn to_train_case(&self) -> Self::Owned;
+}
+
+impl ToTrainCase for str {
+ fn to_train_case(&self) -> Self::Owned {
+ AsTrainCase(self).to_string()
+ }
+}
+
+/// This wrapper performs a train case conversion in [`fmt::Display`].
+///
+/// ## Example:
+///
+/// ```
+/// use heck::AsTrainCase;
+///
+/// let sentence = "We are going to inherit the earth.";
+/// assert_eq!(format!("{}", AsTrainCase(sentence)), "We-Are-Going-To-Inherit-The-Earth");
+/// ```
+pub struct AsTrainCase<T: AsRef<str>>(pub T);
+
+impl<T: AsRef<str>> fmt::Display for AsTrainCase<T> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ transform(self.0.as_ref(), capitalize, |f| write!(f, "-"), f)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::ToTrainCase;
+
+ macro_rules! t {
+ ($t:ident : $s1:expr => $s2:expr) => {
+ #[test]
+ fn $t() {
+ assert_eq!($s1.to_train_case(), $s2)
+ }
+ };
+ }
+
+ t!(test1: "CamelCase" => "Camel-Case");
+ t!(test2: "This is Human case." => "This-Is-Human-Case");
+ t!(test3: "MixedUP CamelCase, with some Spaces" => "Mixed-Up-Camel-Case-With-Some-Spaces");
+ t!(test4: "mixed_up_ snake_case with some _spaces" => "Mixed-Up-Snake-Case-With-Some-Spaces");
+ t!(test5: "kebab-case" => "Kebab-Case");
+ t!(test6: "SHOUTY_SNAKE_CASE" => "Shouty-Snake-Case");
+ t!(test7: "snake_case" => "Snake-Case");
+ t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "This-Contains-All-Kinds-Of-Word-Boundaries");
+ #[cfg(feature = "unicode")]
+ t!(test9: "XΣXΣ baffle" => "Xσxς-Baffle");
+ t!(test10: "XMLHttpRequest" => "Xml-Http-Request");
+ t!(test11: "FIELD_NAME11" => "Field-Name11");
+ t!(test12: "99BOTTLES" => "99bottles");
+ t!(test13: "FieldNamE11" => "Field-Nam-E11");
+ t!(test14: "abc123def456" => "Abc123def456");
+ t!(test16: "abc123DEF456" => "Abc123-Def456");
+ t!(test17: "abc123Def456" => "Abc123-Def456");
+ t!(test18: "abc123DEf456" => "Abc123-D-Ef456");
+ t!(test19: "ABC123def456" => "Abc123def456");
+ t!(test20: "ABC123DEF456" => "Abc123def456");
+ t!(test21: "ABC123Def456" => "Abc123-Def456");
+ t!(test22: "ABC123DEf456" => "Abc123d-Ef456");
+ t!(test23: "ABC123dEEf456FOO" => "Abc123d-E-Ef456-Foo");
+ t!(test24: "abcDEF" => "Abc-Def");
+ t!(test25: "ABcDE" => "A-Bc-De");
+}