Enum full_moon::ast::punctuated::Pair
source · 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§
source§impl<T> Pair<T>
impl<T> Pair<T>
sourcepub fn new(value: T, punctuation: Option<TokenReference>) -> Self
pub fn new(value: T, punctuation: Option<TokenReference>) -> Self
Creates a Pair
with node T
and optional punctuation
let pair = Pair::new(1, None);
sourcepub fn into_tuple(self) -> (T, Option<TokenReference>)
pub fn into_tuple(self) -> (T, Option<TokenReference>)
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));
sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Takes the Pair
and returns the node T
let pair = Pair::new(1, None);
assert_eq!(pair.into_value(), 1);
sourcepub fn value(&self) -> &T
pub fn value(&self) -> &T
Returns a reference to the node T
let pair = Pair::new(1, None);
assert_eq!(pair.value(), &1);
sourcepub fn value_mut(&mut self) -> &mut T
pub fn value_mut(&mut self) -> &mut T
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);
sourcepub fn punctuation(&self) -> Option<&TokenReference>
pub fn punctuation(&self) -> Option<&TokenReference>
Returns the trailing punctuation, if it exists
let pair = Pair::new(1, None);
assert_eq!(pair.punctuation(), None);
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Pair<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Pair<T>where T: Deserialize<'de>,
source§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
source§impl<T> Extend<Pair<T>> for Punctuated<T>
impl<T> Extend<Pair<T>> for Punctuated<T>
source§fn extend<I: IntoIterator<Item = Pair<T>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Pair<T>>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl<T> FromIterator<Pair<T>> for Punctuated<T>
impl<T> FromIterator<Pair<T>> for Punctuated<T>
source§impl<T: Node> Node for Pair<T>
impl<T: Node> Node for Pair<T>
source§fn start_position(&self) -> Option<Position>
fn start_position(&self) -> Option<Position>
The start position of a node. None if can’t be determined
source§fn end_position(&self) -> Option<Position>
fn end_position(&self) -> Option<Position>
The end position of a node. None if it can’t be determined
source§fn similar(&self, other: &Self) -> bool
fn similar(&self, other: &Self) -> bool
Whether another node of the same type is the same as this one semantically, ignoring position
source§impl<T: PartialEq> PartialEq for Pair<T>
impl<T: PartialEq> PartialEq for Pair<T>
impl<T: Eq> Eq for Pair<T>
impl<T> StructuralEq for Pair<T>
impl<T> StructuralPartialEq for Pair<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Pair<T>where T: RefUnwindSafe,
impl<T> Send for Pair<T>where T: Send,
impl<T> Sync for Pair<T>where T: Sync,
impl<T> Unpin for Pair<T>where T: Unpin,
impl<T> UnwindSafe for Pair<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more