string
String manipulation and formatting helpers.
Install
Section titled “Install”Cargo feature string (enabled by default). To compile only this module:
or in Cargo.toml:
Import path: helpers4::string.
| Item | What it does |
|---|---|
camel_case | Converts s to camelCase. |
capitalize | Uppercases the first character of s and leaves the rest untouched. |
constant_case | Converts s to CONSTANT_CASE (also known as SCREAMING_SNAKE_CASE). |
dedent | Strips the indentation shared by every non-blank line of s, and drops one leading and one trailing blank line. |
escape_html | Escapes the HTML special characters &, <, >, " and '. |
indent | Prefixes every non-blank line of s with prefix. |
kebab_case | Converts s to kebab-case. |
pascal_case | Converts s to PascalCase. |
slugify | Converts s into a lowercase, hyphen-separated slug safe for URLs. |
snake_case | Converts s to snake_case. |
squish | Trims s and collapses every run of whitespace into a single space. |
title_case | Capitalizes the first letter of every whitespace-separated word and lowercases the rest. |
truncate | Shortens s to at most max_chars characters, ending with suffix when it was cut. |
unescape_html | Decodes the HTML entities &, <, >, ", ', ' and any numeric character reference (A, A). |
