Macro compare
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) => { ... };
}
Available on crate feature
dep_const_str
only.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));