Skip to content

Commit

Permalink
new: added Caser that attaches methods for converting cases to strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk committed Feb 25, 2024
1 parent cb3dfc6 commit e68deb0
Show file tree
Hide file tree
Showing 4 changed files with 712 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
@@ -1,6 +1,7 @@
# [stringcase-rust][repo-url] [![crate.io][crateio-img]][crateio-url] [![doc.rs][docrs-img]][docrs-url] [![CI Status][ci-img]][ci-url] [![MIT License][mit-img]][mit-url]

This library provides some functions that convert string cases between camelCase, COBOL-CASE, kebab-case, MACRO_CASE, PascalCase, snake_case and Train-Case.
And this library also provides a trait `Caser` which has some methods to convert string cases.

Basically, these functions targets the upper and lower cases of only ASCII alphabets for capitalization, and all characters except ASCII alphabets and ASCII numbers are eliminated as word separators.

Expand All @@ -17,7 +18,7 @@ stringcase = "0.1.1"

## Usage

The function contained in this crate are executed as follows:
The function contained in this crate can be executed as follows:

```rust
use stringcase::camel_case;
Expand All @@ -29,6 +30,19 @@ fn main() {
}
```

And by bringing `Caser` with `use` declaration, it will be able to execute methods of
strings, `String` or `&str`, to convert their cases.

```rust
use stringcase::Caser;

func main() {
let input = "foo-bar-baz";
let camel = input.to_camel_case();
assert_eq!(camel, "fooBarBaz");
}
```

## Supporting Rust versions

This library supports Rust 1.56.1 or later.
Expand All @@ -43,7 +57,7 @@ Check for toolchain '1.61.0-x86_64-apple-darwin' succeeded
Check for toolchain '1.58.1-x86_64-apple-darwin' succeeded
Check for toolchain '1.57.0-x86_64-apple-darwin' succeeded
Check for toolchain '1.56.1-x86_64-apple-darwin' succeeded
Finished The MSRV is: 1.56.1 ████████████████████████████████████████████████████████████████ 00:02:42
Finished The MSRV is: 1.56.1 █████████████████████████████████████ 00:00:20
```

## License
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Expand Up @@ -34,7 +34,9 @@ unit() {

cover() {
cargo llvm-cov clean
errcheck $?
cargo llvm-cov --html --quiet
errcheck $?
cargo llvm-cov report
errcheck $?
}
Expand Down

0 comments on commit e68deb0

Please sign in to comment.