#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
#[non_exhaustive]
pub enum XPathVersion {
#[default]
V1,
V2,
}
impl XPathVersion {
#[must_use]
pub const fn is_v2(self) -> bool {
matches!(self, XPathVersion::V2)
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
XPathVersion::V1 => "XPath 1.0",
XPathVersion::V2 => "XPath 2.0",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_default_is_xpath_one() {
assert_eq!(XPathVersion::default(), XPathVersion::V1);
assert!(!XPathVersion::default().is_v2());
}
#[test]
fn versions_are_named_for_error_messages() {
assert_eq!(XPathVersion::V1.as_str(), "XPath 1.0");
assert_eq!(XPathVersion::V2.as_str(), "XPath 2.0");
}
}