Macro const_str::compare

source ·
macro_rules! compare {
    (<, $lhs: expr, $rhs: expr) => { ... };
    (>, $lhs: expr, $rhs: expr) => { ... };
    (==, $lhs: expr, $rhs: expr) => { ... };
    (<=, $lhs: expr, $rhs: expr) => { ... };
    (>=, $lhs: expr, $rhs: expr) => { ... };
    ($lhs: expr, $rhs: expr) => { ... };
}
Expand description

Compares two strings lexicographically.

§Examples

use core::cmp::Ordering;

const A: &str = "1";
const B: &str = "10";
const C: &str = "2";

const ORD: Ordering = const_str::compare!(A, B);
assert_eq!(ORD, Ordering::Less);

assert!(const_str::compare!(<, A, B));
assert!(const_str::compare!(<=, A, B));

assert!(const_str::compare!(>, C, A));
assert!(const_str::compare!(>=, C, A));

assert!(const_str::compare!(==, A, A));