Crate const_str[−][src]
Expand description
Compile-time string operations
MSRV: Rust 1.52.0
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
Checks that two strings are equal.
Converts a byte string literal to a string literal
Returns the length of a string slice or a byte string
Asserts that the string literal matches the pattern.
Creates a new string slice by repeating a string slice n times.
Replaces all matches of a pattern with another string literal.
Returns a copy of this string where each character is mapped to its ASCII lower case equivalent.
Returns a copy of this string where each character is mapped to its ASCII upper case equivalent.
Converts a string slice or a byte string to a byte array.
Converts a string literal to camel case.
Converts a string literal into an array of its characters.
Converts a string literal to kebab case.
Returns the lowercase equivalent of this string literal, as a new string literal.
Converts a string literal to shouty kebab case.
Converts a string literal to shouty snake case.
Converts a string literal to snake case.
Returns the uppercase equivalent of this string literal, as a new string literal.
Returns a compile-time verified header name string literal.
Returns a compile-time verified regex string literal.