pub enum Pair<T> {
End(T),
Punctuated(T, TokenReference),
}
Expand description
A node T
followed by the possible trailing
TokenReference
.
Refer to the module documentation for more details.
Variants
End(T)
A node T
with no trailing punctuation
Punctuated(T, TokenReference)
A node T
followed by punctuation (in the form of a
TokenReference
)
Implementations
Creates a Pair
with node T
and optional punctuation
let pair = Pair::new(1, None);
Takes the Pair
and returns the node T
and the punctuation, if it exists as a tuple
let pair = Pair::new(1, None);
assert_eq!(pair.into_tuple(), (1, None));
Takes the Pair
and returns the node T
let pair = Pair::new(1, None);
assert_eq!(pair.into_value(), 1);
Returns a reference to the node T
let pair = Pair::new(1, None);
assert_eq!(pair.value(), &1);
Returns a mutable reference to the node T
let mut pair = Pair::new(1, None);
*pair.value_mut() += 1;
assert_eq!(pair.into_value(), 2);
Returns the trailing punctuation, if it exists
let pair = Pair::new(1, None);
assert_eq!(pair.punctuation(), None);
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
The start position of a node. None if can’t be determined
The end position of a node. None if it can’t be determined
Whether another node of the same type is the same as this one semantically, ignoring position
The token references that comprise a node
The full range of a node, if it has both start and end positions
Auto Trait Implementations
impl<T> RefUnwindSafe for Pair<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Pair<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more