mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1817900 - Update heck to 0.4.1. r=emilio,supply-chain-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D170437
This commit is contained in:
parent
11b433e418
commit
4a33291f58
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2538,9 +2538,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
|
@ -1216,6 +1216,11 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-run"
|
||||
delta = "0.3.7 -> 0.3.8"
|
||||
|
||||
[[audits.heck]]
|
||||
who = "Mike Hommey <mh+mozilla@glandium.org>"
|
||||
criteria = "safe-to-deploy"
|
||||
delta = "0.4.0 -> 0.4.1"
|
||||
|
||||
[[audits.hex]]
|
||||
who = "Simon Friedberger <simon@mozilla.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
2
third_party/rust/heck/.cargo-checksum.json
vendored
2
third_party/rust/heck/.cargo-checksum.json
vendored
@ -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"}
|
||||
{"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"}
|
6
third_party/rust/heck/CHANGELOG.md
vendored
6
third_party/rust/heck/CHANGELOG.md
vendored
@ -1,3 +1,9 @@
|
||||
# 0.4.1
|
||||
|
||||
Improvements:
|
||||
|
||||
- Add Train-Case support
|
||||
|
||||
# 0.4.0
|
||||
|
||||
Breaking changes:
|
||||
|
18
third_party/rust/heck/Cargo.toml
vendored
18
third_party/rust/heck/Cargo.toml
vendored
@ -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
|
||||
|
1
third_party/rust/heck/README.md
vendored
1
third_party/rust/heck/README.md
vendored
@ -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
|
||||
|
||||
|
5
third_party/rust/heck/src/lib.rs
vendored
5
third_party/rust/heck/src/lib.rs
vendored
@ -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,
|
||||
};
|
||||
|
85
third_party/rust/heck/src/train.rs
vendored
Normal file
85
third_party/rust/heck/src/train.rs
vendored
Normal file
@ -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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user