String
length
Section titled “length”fn length(s: String) -> IntThe number of user-perceived characters (grapheme clusters). "👍".length() is 1.
byte_size
Section titled “byte_size”fn byte_size(s: String) -> IntThe number of bytes in UTF-8.
append
Section titled “append”fn append(a: String, b: String) -> StringJoins two strings: "ab".append("cd") is "abcd".
concat
Section titled “concat”fn concat(parts: List[String]) -> StringJoins all the strings in order: String.concat(["a", "b", "c"]) is "abc".
contains
Section titled “contains”fn contains(s: String, sub: String) -> BoolMatches by code point sequence.
starts_with
Section titled “starts_with”fn starts_with(s: String, prefix: String) -> BoolWhether s starts with prefix.
ends_with
Section titled “ends_with”fn ends_with(s: String, suffix: String) -> BoolWhether s ends with suffix.
fn split(s: String, sep: String) -> List[String]Splits into grapheme clusters if sep is empty.
s.split(sep).join(sep) == s holds.
fn chars(s: String) -> List[String]One string per grapheme cluster.
fn join(parts: List[String], sep: String) -> StringMoved to List.join, so that it reads as parts.join(", ").
fn trim(s: String) -> StringRemoves leading and trailing whitespace (Unicode White_Space).
code_points
Section titled “code_points”fn code_points(s: String) -> List[Int]The code point values of s, in order.
from_code_point
Section titled “from_code_point”fn from_code_point(n: Int) -> Option[String]None if n is not a Unicode scalar value (0 to 10FFFF, excluding surrogates).
show_nested
Section titled “show_nested”fn show_nested[A: Show](value: A) -> StringThe Show of a value shown inside another value ([trait.builtin]): a String is quoted and
escaped ("a\"b"), any other type is its Show.show. For the Show impls in core ([1, 2],
["a"]).
to_ascii_lowercase
Section titled “to_ascii_lowercase”fn to_ascii_lowercase(s: String) -> Strings with A to Z changed to a to z. Other characters, including non-ASCII letters, are left as
they are.
to_ascii_uppercase
Section titled “to_ascii_uppercase”fn to_ascii_uppercase(s: String) -> Strings with a to z changed to A to Z. Other characters, including non-ASCII letters, are left as
they are.