Skip to main content

Module string

Module string 

Source
Expand description

String conversion, formatting, parsing, serialization, and slicing utilities.

The module includes borrowed unquoted views, Serde adapters, chunking, case conversion, deterministic prefix selection, and UTF-8 conversion. Specialized display wrappers avoid allocation. String traits and helpers are re-exported from child modules.

Re-exportsยง

use std::borrow::Cow; ๐Ÿ”’
use std::fmt; ๐Ÿ”’
use std::fmt::write; ๐Ÿ”’
use std::io; ๐Ÿ”’
use std::mem::replace; ๐Ÿ”’
use std::ops::Range; ๐Ÿ”’
use std::ops::RangeInclusive; ๐Ÿ”’
use std::str::from_utf8; ๐Ÿ”’
pub use self::between::Between;
pub use self::chunk::chunk;
pub use self::split::SplitInfallible;
pub use self::unquote::Unquote;
pub use self::unquoted::Unquoted;
use crate::Result; ๐Ÿ”’
use crate::arrayvec::ArrayString; ๐Ÿ”’
use crate::smallstr::SmallString; ๐Ÿ”’

Modulesยง

between ๐Ÿ”’
chunk ๐Ÿ”’
Budget-driven text segmentation. The size budget is injected as a fits predicate, so the caller owns measurement; markdown mode keeps code fences self-contained across segment boundaries.
de
Serde deserializers for normalized strings.
split ๐Ÿ”’
unquote ๐Ÿ”’
unquoted ๐Ÿ”’

Constantsยง

EMPTY
Provides a shared empty string slice.
OPAQUE_ID_LENGTHS ๐Ÿ”’

Functionsยง

camel_to_snake_case
Streams ASCII camel-case bytes into a writer as lowercase snake case.
camel_to_snake_string
Converts ASCII camel-case text into an owned lowercase snake-case string.
collect_stream
Collects text emitted by a callback into an owned string.
common_prefix
Returns the longest common ASCII prefix of a collection of strings.
contains_any
Reports whether haystack contains any of the non-empty needles.
equals_any
Reports whether any of candidates equals item.
format_array_string
Formats arguments into an array string with constant byte capacity.
format_small_string
Formats arguments into a small string with an inline byte capacity.
is_opaque_id
Reports whether a string is a Matrix opaque identifier.
is_unreserved
Reports whether every byte of a string is unreserved.
is_unreserved_byte
Reports whether a byte is an RFC 3986 unreserved character.
markdown_cell
Escapes a value for one markdown table cell.
plural
Picks the singular or plural form of a noun for a count.
single_line
Replaces control characters and Unicode line separators with spaces.
str_from_bytes
Borrows a byte slice as UTF-8 text.
string_from_bytes
Converts UTF-8 bytes into an owned string.
to_array_string
Displays a value into an array string with constant byte capacity.
to_small_string
Displays a value into a small string with an inline byte capacity.
truncate_chars
Shortens a string to at most max characters.
truncate_deterministic
Returns a deterministic prefix selected from the string contents.
try_format_array_string
Formats arguments into an array string, propagating any formatting error.
try_format_small_string
Formats arguments into a small string, propagating any formatting error.