pub enum Value<N> {
NodeSet(Vec<N>),
Boolean(bool),
Number(f64),
String(String),
}Expand description
An XPath 1.0 value: one of the four object types (§3.1) — “node-set (an unordered collection of nodes without duplicates), boolean, number … [or] string”.
Parameterized only over the node type N, not over a separate lifetime
— a concrete N already implements Node<'a> for one specific 'a
(e.g. TestNode<'a>), so that lifetime doesn’t need to be repeated here
(the plan’s sketched Value<'a, N: Node<'a>> shape is adjusted to avoid
an otherwise-unused lifetime parameter on the enum itself).
Variants§
NodeSet(Vec<N>)
Boolean(bool)
Number(f64)
An IEEE-754 double-precision floating point number.
String(String)
Implementations§
Source§impl<'a, N: Node<'a>> Value<N>
impl<'a, N: Node<'a>> Value<N>
Sourcepub fn to_boolean(&self) -> bool
pub fn to_boolean(&self) -> bool
§4.3, verbatim: “a number is true if and only if it is neither positive or negative zero nor NaN; a node-set is true if and only if it is non-empty; a string is true if and only if its length is non-zero”.
Sourcepub fn to_number(&self) -> f64
pub fn to_number(&self) -> f64
§4.4: string→number (via the node-set→string→number chain for node-sets), boolean→number (“true is converted to 1; false to 0”), and the identity for numbers.
Sourcepub fn to_xpath_string(&self) -> String
pub fn to_xpath_string(&self) -> String
§4.2: node-set→string (“the string-value of the node … that is
first in document order. If the node-set is empty, an empty string
is returned”), number→string (see number_to_string), and
boolean→string (“false”/“true”).
Named to_xpath_string rather than to_string so this inherent
method does not collide with (and get flagged by clippy as shadowing)
std::string::ToString — Value deliberately does not implement
Display/ToString.