3 releases (1 stable)

Uses old Rust 2015

1.0.0 Nov 21, 2018
0.1.0 Dec 28, 2016
0.0.1 Jun 1, 2015

#708 in Text processing

Download history 10841/week @ 2024-12-02 9711/week @ 2024-12-09 9145/week @ 2024-12-16 5065/week @ 2024-12-23 5886/week @ 2024-12-30 8882/week @ 2025-01-06 9518/week @ 2025-01-13 9612/week @ 2025-01-20 8379/week @ 2025-01-27 11515/week @ 2025-02-03 12455/week @ 2025-02-10 13403/week @ 2025-02-17 17758/week @ 2025-02-24 16600/week @ 2025-03-03 18107/week @ 2025-03-10 13442/week @ 2025-03-17

66,500 downloads per month
Used in 432 crates (38 directly)

MIT license

8KB
89 lines

case

This is a set of letter case string helpers.

Installation

If you're using Cargo, just add case to your Cargo.toml:

[dependencies]
case = "1.0.0"

Usage

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-do

  • to_human/to_human_lowercase: convert underscores to spaces and optionally capitalize the first character
  • to_title: convert underscores to spaces and capitalize each word's first character

No runtime deps