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

#346 in Text processing

Download history 15285/week @ 2023-10-24 15841/week @ 2023-10-31 15197/week @ 2023-11-07 14916/week @ 2023-11-14 14928/week @ 2023-11-21 15471/week @ 2023-11-28 14875/week @ 2023-12-05 12232/week @ 2023-12-12 11854/week @ 2023-12-19 5674/week @ 2023-12-26 14704/week @ 2024-01-02 15576/week @ 2024-01-09 14628/week @ 2024-01-16 16389/week @ 2024-01-23 13013/week @ 2024-01-30 10547/week @ 2024-02-06

57,177 downloads per month
Used in 335 crates (30 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