macro_rules! str {
(compare: $($t:tt)*) => { ... };
(concat: $($t:tt)*) => { ... };
(concat_bytes: $($t:tt)*) => { ... };
(contains: $($t:tt)*) => { ... };
(cstr: $($t:tt)*) => { ... };
(encode: $($t:tt)*) => { ... };
(encode_z: $($t:tt)*) => { ... };
(ends_with: $($t:tt)*) => { ... };
(equal: $($t:tt)*) => { ... };
(from_utf8: $($t:tt)*) => { ... };
(hex: $($t:tt)*) => { ... };
(join: $($t:tt)*) => { ... };
(parse: $($t:tt)*) => { ... };
(raw_cstr: $($t:tt)*) => { ... };
(repeat: $($t:tt)*) => { ... };
(replace: $($t:tt)*) => { ... };
(sorted: $($t:tt)*) => { ... };
(split: $($t:tt)*) => { ... };
(starts_with: $($t:tt)*) => { ... };
(strip_prefix: $($t:tt)*) => { ... };
(strip_suffix: $($t:tt)*) => { ... };
(to_byte_array: $($t:tt)*) => { ... };
(to_char_array: $($t:tt)*) => { ... };
(to_str: $($t:tt)*) => { ... };
(
is_ascii: $($t:tt)*) => { ... };
(convert_ascii_case: $($t:tt)*) => { ... };
(eq_ignore_ascii_case: $($t:tt)*) => { ... };
(squish: $($t:tt)*) => { ... };
(unwrap: $($t:tt)*) => { ... };
}
Available on crate feature
dep_const_str
only.Expand description
&str
compile-time operations, namespaced from the const-str crate.
The name of each operation links to the original macro documentation.
§Operations
compare:
Compares two&str
lexicographically.concat:
Concatenates (&str
|char
|bool
|u*
|i*
) into a&str
.concat_bytes:
Concatenates (&str
|u8
|&[u8]
|[u8; N]
|&[u8; N]
) to&[u8; _]
.contains:
Returnstrue
if the given pattern (&str
|char
) matches a sub-&str
.cstr:
Converts a&str
to&CStr
.encode:
Encodes a&str
with an encoding (utf8
|utf16
).encode_z:
Encodes a&str
with an encoding (utf8
|utf16
) and append a NUL char.ends_with:
Returnstrue
if the given pattern matches a suffix of this&str
.equal:
Returnstrue
if two&str
are equal.from_utf8:
Returns a&str
from a&[u8]
. Panics if it’s not valid utf8.hex:
Converts a&str
with hexadecimals (0-9
|A-F
|a-f
) into a[u8; _]
.join:
Concatenates multiple&str
into a &str separated by the given separator.parse:
Parses a&str
into a value (&str
|char
|bool
|u*
|i*
).raw_cstr:
Converts a&str
into a*const c_char
.repeat:
Creates a&str
by repeating a&str
n times.replace:
Replaces all matches of a pattern (&str
|char
) with another&str
.sorted:
Sorts multiple (&[&str]
|[&str; N]
|&[&str; N]
) into a[&str; _]
.split:
Splits a&str
by a separator pattern (&str
|char
) returning[&str; _]
.starts_with:
Returnstrue
if the given pattern (&str
|char
) matches a prefix of&str
.strip_prefix:
Returns a&str
with the prefix removed.strip_suffix:
Returns a&str
with the suffix removed.to_byte_array:
Converts a&str
or&[u8]
into a[u8; _]
.to_char_array:
Converts a&str
into a[char; _]
.to_str:
Returns a&str
from a value (&str
|char
|bool
|u*
|i*
).unwrap:
Unwraps a container, returns the content (see also theunwrap!
macro).
Ascii related:
convert_ascii_case:
Converts a&str
to a specified case. Non-ASCII characters are not affected.eq_ignore_ascii_case:
Returnstrue
if two&str
are an ASCII case-insensitive match.is_ascii:
Returnstrue
if all codes in this (&str
|&[u8]
|&[u8; N]
) are ASCII.squish:
Splits a&str
by ASCII whitespaces, and joins the parts with a single space.