Function konst::string::cmp_str

source ·
pub const fn cmp_str(left: &str, right: &str) -> Ordering
Expand description

A const equivalent of str::cmp.

§Example

use konst::cmp_str;

use std::cmp::Ordering;

const FOO: &str = "foo";
const BAR: &str = "fooooo";
const BAZ: &str = "bar";


const FOO_CMP_FOO: Ordering = cmp_str(FOO, FOO);
assert_eq!(FOO_CMP_FOO, Ordering::Equal);

const FOO_CMP_BAR: Ordering = cmp_str(FOO, BAR);
assert_eq!(FOO_CMP_BAR, Ordering::Less);

const FOO_CMP_BAZ: Ordering = cmp_str(FOO, BAZ);
assert_eq!(FOO_CMP_BAZ, Ordering::Greater);