truncate
Shortens s to at most max_chars characters, ending with suffix when it was cut.
The suffix counts toward the limit. Lengths are in Unicode scalar values (chars), not
grapheme clusters. If the suffix alone does not fit, the first max_chars characters of the
suffix are returned.
Import
Section titled “Import”Cargo feature string (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
s | &str | The text to shorten. |
max_chars | usize | The maximum length of the result, suffix included. |
suffix | &str | Appended when s was cut. |
Returns
Section titled “Returns”String
