Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Converts to and from various cases.

License

NotificationsYou must be signed in to change notification settings

rutrum/convert-case

Repository files navigation

Converts to and from various cases.

Rust Libraryconvert_case

Convert case was written in Rust and is ready to be used inline with your rust code as a library.

use convert_case::{Case, Casing};assert_eq!("ronnieJamesDio", "Ronnie_James_dio".to_case(Case::Camel));assert_eq!("io_stream", "IOStream".to_case(Case::Snake));assert_eq!(    "2020-04-16 My Cat Cali",    "2020-04-16_my_cat_cali".from_case(Case::Snake).to_case(Case::Title));

You can read the API documentation ondocs.rs for a list of all features and read lots of examples.

Command Line Utilityccase

Thecommand line utilityccase was made to expose the tools of theconvert_case library to the command line.

$ ccase -t title super_mario_64Super Mario 64$ ccase -f snake -t title 2020-04-15_my_cat_cali2020-04-16 My Cat Cali$ ccase -t camel "convert to camel"convertToCamel

Links

convert_caseccase
Repositorygithubgithub
Cratecrates.iocrates.io
Documentationdocs.rs

Cases

This is list of cases that convert_case supports. Some cases are simply aliases of others. The "Random" and "PseudoRandom" cases are provided in theconvert_case library with the "random" feature.

CaseExample
Snakemy_variable_name
Constant
UpperSnake
MY_VARIABLE_NAME
AdaMy_Variable_Name
Kebabmy-variable-name
Cobol
UpperKebab
MY-VARIABLE-NAME
TrainMy-Variable-Name
Flatmyvariablename
UpperFlatMYVARIABLENAME
Pascal
UpperCamel
MyVariableName
CamelmyVariableName
UpperMY VARIABLE NAME
Lowermy variable name
TitleMy Variable Name
SentenceMy variable name
AlternatingmY vArIaBlE nAmE
TogglemY vARIABLE nAME
RandomMY vaRiabLe nAME
PseudoRandommY VaRiAblE nAMe

Change Log

0.8.0: Pattern Overhaul, Custom Case

Pattern is no longer an enum. It is now a type alias forfn(&[&str]) -> Vec<String>. The variants of Pattern can now be referenced as functions inside thepattern module. For upgrading this means changingPattern::Lowercase topattern::lowercase, and calling the function directly instead of invoking themutate method on the enum.

Inside the pattern module is also the type aliasPattern itself.

Other breaking changes:

  • AddCase::Ada (capital pattern with underscore delimiter.)
  • AddCase::Custom variant. It is a struct variant that takes three parameters:
    • pattern with typePattern
    • delim with type&static str, and
    • boundaries with type&'static [Boundary].
  • Because of the newpattern::noop function,Converter attributepattern is now of typePattern and notOption<Pattern>
  • Case::deterministic_cases,Case::all_cases, andCase::random_cases now return static arrays instead of vecs

Other changes:

  • AddedCase::split,Case::mutate, andCase::join which expose operations related to the boundaries, pattern, and delimiter of a case
  • Is nowno_std compatible

0.7.1

  • Removed debug print statement.

0.7.0: Custom Boundaries

Boundary is no longer an enum. It now is a struct, and each enum variant cooresponds to an associated constant. For upgrading this just means changingBoundary::LowerUpper to justBoundary::LOWER_UPPER.

The benefit of this is that you can make your boundary conditions now, by instantiating theBoundary struct, or usingBoundary::from_delim(). Now you can split on newlines, periods, double-colons, emojis, or a more complex case like a symbol followed by a digit. You also define which characters, if any, are removed during segmentation, and where the split happens.

Changes from this feature:

  • PreviousBoundary::PascalName enum variants now much refered to asBoundary::CONSTANT_NAME constants.
  • All functions that returned groups of boundaries (such asBoundary::defaults(),Boundary::digit_letter(), etc) now are const and return fixed-sized arrays[Boundary; N], notVec<Boundary>.
  • Boundary::all() was removed, since there's no longer a sense of "all" boundaries, since you can create your own.
  • Boundary::list_from() has been renamed toBoundary::defaults_from() and no longer outputsBoundary::UPPER_LOWER, since this function now only checks default boundaries.
  • Create custom delimiter boundaries usingBoundary::from_delim().

Other breaking changes:

  • RenameCase::ScreamingSnake toCase::Constant.
  • AddCase::Sentence (sentence pattern and space delimiter.)
  • Casing trait implemented forArc<str> andRc<str> again.

Other changes:

  • Remove most imports from doc comments.
  • Remove loop overstr::chars in favor ofgraphemes fromunicode-segmentation.

Other Projects

Github userWild-W has builtnodejs bindings for convert_case that are up to date with 0.6.0.

About

Converts to and from various cases.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp