Function display_utils::cmp [−][src]
pub fn cmp<T: Display>(this: T, other: &str) -> Ordering
Lexicographically compares a Display object against a string.
cmp(a, b)
is functionally equivalent to a.to_string().cmp(b)
, but requires no allocations.
use std::cmp::Ordering; assert_eq!(cmp(true, "trud"), Ordering::Greater); assert_eq!(cmp(true, "true"), Ordering::Equal); assert_eq!(cmp(true, "truf"), Ordering::Less);