Crates.io | convert_string |
lib.rs | convert_string |
version | 0.1.3 |
source | src |
created_at | 2023-08-29 21:17:06.190457 |
updated_at | 2023-11-25 21:14:55.534548 |
description | A trait to convert Strings to safe non-keywords and/or convert a Strings case (snake_case, PascalCase, ...). |
homepage | |
repository | https://github.com/Thomblin/convert_string |
max_upload_size | |
id | 958473 |
size | 24,025 |
A trait for String-like types to check if a string is a reserved keyword, and convert it to a safe non-keyword if so. Offers some type conversions as well
Only strict and reserved keywords are checked against; weak keywords are not include
You can add this dependency with:
[dependencies]
convert_string = "0.1.3"
use convert_string::ConvertString;;
assert_eq!("r_type", String::from("type").to_valid_key(&String::from("r")));
assert_eq!("foo", String::from("ns:foo").remove_namespace());
assert_eq!("YdTax", String::from("yd_tax").to_pascal_case());
assert_eq!("yd_tax", String::from("YdTax").to_snake_case());
By default, the keywords added in Rust Edition 2018 are included in the list of chec
This can be disabled with default-features = false
in your Cargo.toml.
[dependencies]
convert_string = { version = "0.1.3", default-features = false }
Future Rust editions may add new keywords, and this crate will be updated to reflect (Or you can create an issue on github if I don't.)
Huge parts of this library are taken from https://github.com/JoelCourtney/check_keyword
License: Apache-2.0