case-switcher

Crates.iocase-switcher
lib.rscase-switcher
version1.0.2
sourcesrc
created_at2023-03-04 13:43:05.181224
updated_at2023-03-04 13:46:31.37263
descriptionLibrary to change the casing of strings.
homepage
repositoryhttps://gitlab.com/mburkard/case-switcher-rs
max_upload_size
id800637
size13,534
Matthew J Burkard (Matthew-Burkard)

documentation

README

Case Switcher

Crates.io Apache 2.0

This library provides functions to change the case convention of a string.

Supported cases:

  • camelCase
  • dot.case
  • kebab-case
  • PascalCase
  • path/case
  • snake_case
  • Title Case

Install

cargo add case-switcher

Demo

use case_switcher as cs;

fn main() {
    let sample = "avocado bagel-coffeeDONUTEclair_food.gravy";

    let result = cs::to_camel(sample);
    assert_eq!(result, "avocadoBagelCoffeeDONUTEclairFoodGravy");

    let result = cs::to_dot(sample);
    assert_eq!(result, "avocado.bagel.coffee.donut.eclair.food.gravy");

    let result = cs::to_kebab(sample);
    assert_eq!(result, "avocado-bagel-coffee-donut-eclair-food-gravy");

    let result = cs::to_pascal(sample);
    assert_eq!(result, "AvocadoBagelCoffeeDONUTEclairFoodGravy");

    let result = cs::to_path(sample);
    assert_eq!(result, "avocado/bagel/coffee/donut/eclair/food/gravy");

    let result = cs::to_snake(sample);
    assert_eq!(result, "avocado_bagel_coffee_donut_eclair_food_gravy");

    let result = cs::to_title(sample);
    assert_eq!(result, "Avocado Bagel Coffee DONUT Eclair Food Gravy");
}

Support The Developer

Buy Me A Coffee
Commit count: 8

cargo fmt