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

#683 in Text processing

Download history 13569/week @ 2024-07-22 14188/week @ 2024-07-29 13815/week @ 2024-08-05 12887/week @ 2024-08-12 12717/week @ 2024-08-19 13236/week @ 2024-08-26 13029/week @ 2024-09-02 14902/week @ 2024-09-09 13106/week @ 2024-09-16 15362/week @ 2024-09-23 11709/week @ 2024-09-30 13565/week @ 2024-10-07 11923/week @ 2024-10-14 15123/week @ 2024-10-21 11393/week @ 2024-10-28 12415/week @ 2024-11-04

51,079 downloads per month
Used in 348 crates (36 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