Function malachite_base::orderings::ordering_from_str
source · pub fn ordering_from_str(src: &str) -> Option<Ordering>
Expand description
Converts a string to an Ordering
.
If the string does not represent a valid Ordering
, None
is returned.
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::orderings::ordering_from_str;
use std::cmp::Ordering::*;
assert_eq!(ordering_from_str("Equal"), Some(Equal));
assert_eq!(ordering_from_str("Less"), Some(Less));
assert_eq!(ordering_from_str("Greater"), Some(Greater));
assert_eq!(ordering_from_str("abc"), None);