Function malachite_base::orderings::ordering_from_str
source · [−]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(Ordering::Equal));
assert_eq!(ordering_from_str("Less"), Some(Ordering::Less));
assert_eq!(ordering_from_str("Greater"), Some(Ordering::Greater));
assert_eq!(ordering_from_str("abc"), None);