Function const_format::utils::str_eq
source · pub const fn str_eq(left: &str, right: &str) -> bool
Available on crate feature
fmt
only.Expand description
A const equivalent of &str
equality comparison.
Example
use const_format::utils::str_eq;
const STRS: &[&str] = &[
"foo",
"fooooo",
"bar",
"baz",
];
const ARE_0_0_EQ: bool = str_eq(STRS[0], STRS[0]);
const ARE_0_1_EQ: bool = str_eq(STRS[0], STRS[1]);
const ARE_1_1_EQ: bool = str_eq(STRS[1], STRS[1]);
const ARE_1_2_EQ: bool = str_eq(STRS[1], STRS[2]);
const ARE_2_2_EQ: bool = str_eq(STRS[2], STRS[2]);
const ARE_2_3_EQ: bool = str_eq(STRS[2], STRS[3]);
assert!( ARE_0_0_EQ );
assert!( !ARE_0_1_EQ );
assert!( ARE_1_1_EQ );
assert!( !ARE_1_2_EQ );
assert!( ARE_2_2_EQ );
assert!( !ARE_2_3_EQ );