3 个版本 (1 个稳定版)

使用旧的 Rust 2015

1.0.0 2018 年 11 月 21 日
0.1.0 2016 年 12 月 28 日
0.0.1 2015 年 6 月 1 日

#599 in 文本处理

Download history · Rust 包仓库 15013/week @ 2024-03-01 · Rust 包仓库 15059/week @ 2024-03-08 · Rust 包仓库 14486/week @ 2024-03-15 · Rust 包仓库 14614/week @ 2024-03-22 · Rust 包仓库 14588/week @ 2024-03-29 · Rust 包仓库 15865/week @ 2024-04-05 · Rust 包仓库 15720/week @ 2024-04-12 · Rust 包仓库 16319/week @ 2024-04-19 · Rust 包仓库 16176/week @ 2024-04-26 · Rust 包仓库 13165/week @ 2024-05-03 · Rust 包仓库 16337/week @ 2024-05-10 · Rust 包仓库 13821/week @ 2024-05-17 · Rust 包仓库 13228/week @ 2024-05-24 · Rust 包仓库 16215/week @ 2024-05-31 · Rust 包仓库 15729/week @ 2024-06-07 · Rust 包仓库 11417/week @ 2024-06-14 · Rust 包仓库

58,975 每月下载量
339 个 crate 中使用 (直接使用 31 个)

MIT 许可证

8KB
89

case

这是一个字母大小写字符串助手的集合。

安装

如果您使用 Cargo,只需将 case 添加到您的 Cargo.toml

[dependencies]
case = "1.0.0"

用法

extern crate case;

use case::CaseExt;

// Snake case operations:
assert_eq!(&"a_string_and_a_miss".to_camel(), "AStringAndAMiss");
assert_eq!(&"string_henry_iii".to_camel_lowercase(), "stringHenryIii");
assert_eq!(&"stringing_in_the_rain".to_dashed(), "stringing-in-the-rain");

// Camel case operations:
assert_eq!(&"martinLutherStringJr".to_snake(), "martin_luther_string_jr");
assert!(&"martinLutherStringJr".is_camel_lowercase());

// Universal operations:
assert_eq!(&"stringy string".to_capitalized(), "Stringy string");
assert!(&"Stringy string".is_capitalized());

待办事项

  • to_human/to_human_lowercase:将下划线转换为空格,并可选地将首字符大写
  • to_title:将下划线转换为空格,并将每个单词的首字符大写

无运行时依赖