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

#719 in Text processing

Download history 13018/week @ 2024-10-02 12423/week @ 2024-10-09 13355/week @ 2024-10-16 14047/week @ 2024-10-23 11754/week @ 2024-10-30 10664/week @ 2024-11-06 9222/week @ 2024-11-13 11498/week @ 2024-11-20 9098/week @ 2024-11-27 10369/week @ 2024-12-04 9965/week @ 2024-12-11 7448/week @ 2024-12-18 5032/week @ 2024-12-25 7266/week @ 2025-01-01 8654/week @ 2025-01-08 7962/week @ 2025-01-15

29,765 downloads per month
Used in 364 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