[−][src]Crate const_str
compile-time string operations
Examples
assert_eq!(const_str::to_lowercase!("HELLO"), "hello"); assert_eq!(const_str::to_uppercase!("hello"), "HELLO"); assert_eq!(const_str::replace!("this is old", "old", "new"), "this is new");
feature verify-regex
use regex::Regex; let re = const_str::verified_regex!(r"^\d{4}-\d{2}-\d{2}$"); assert!(Regex::new(re).is_ok()); const_str::regex_assert_match!(r"^\d{4}-\d{2}-\d{2}$", "2014-01-01");
feature verify-http
use http::header::HeaderName; let name = const_str::verified_header_name!("content-md5"); assert_eq!(HeaderName::from_static(name).as_str(), "content-md5");
Macros
as_bytes | Converts a string literal to a byte string literal |
from_utf8 | Converts a byte string literal to a string literal |
len | Returns the length of a string literal or byte string literal |
regex_assert_match | Asserts that the string literal matches the pattern. |
replace | Replaces all matches of a pattern with another string literal. |
to_camel_case | Converts a string literal to camel case. |
to_kebab_case | Converts a string literal to kebab case. |
to_lowercase | Returns the lowercase equivalent of this string literal, as a new string literal. |
to_shouty_kebab_case | Converts a string literal to shouty kebab case. |
to_shouty_snake_case | Converts a string literal to shouty snake case. |
to_snake_case | Converts a string literal to snake case. |
to_uppercase | Returns the uppercase equivalent of this string literal, as a new string literal. |
verified_header_name | Returns a compile-time verified header name string literal. |
verified_regex | Returns a compile-time verified regex string literal. |