[−][src]Enum full_moon::ast::punctuated::Pair
A node T
followed by the possible trailing
TokenReference
.
Refer to the module documentation for more details.
Variants
A node T
with no trailing punctuation
Punctuated(T, Cow<'a, TokenReference<'a>>)
A node T
followed by punctuation (in the form of a
TokenReference
)
Implementations
impl<'a, T> Pair<'a, T>
[src]
pub fn new(value: T, punctuation: Option<Cow<'a, TokenReference<'a>>>) -> Self
[src]
Creates a Pair
with node T
and optional punctuation
let pair = Pair::new(1, None);
pub fn into_tuple(self) -> (T, Option<Cow<'a, TokenReference<'a>>>)
[src]
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));
pub fn into_value(self) -> T
[src]
Takes the Pair
and returns the node T
let pair = Pair::new(1, None); assert_eq!(pair.into_value(), 1);
pub fn value(&self) -> &T
[src]
Returns a reference to the node T
let pair = Pair::new(1, None); assert_eq!(pair.value(), &1);
pub fn value_mut(&mut self) -> &mut T
[src]
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);
pub fn punctuation(&self) -> Option<&TokenReference<'a>>
[src]
Returns the trailing punctuation, if it exists
let pair = Pair::new(1, None); assert_eq!(pair.punctuation(), None);
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Pair<'a, U>
[src]
Maps a Pair<'a, T>
to a Pair<'a, U>
by applying a function to the value of the pair,
while preserving punctuation if it is not the end.
let pair = Pair::new(2, None); assert_eq!(*pair.map(|i| i * 2).value(), 4);
Trait Implementations
impl<'a, T: Clone> Clone for Pair<'a, T>
[src]
impl<'a, T: Debug> Debug for Pair<'a, T>
[src]
impl<'de: 'a, 'a, T> Deserialize<'de> for Pair<'a, T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<'a, T> Display for Pair<'a, T> where
T: Display,
[src]
T: Display,
impl<'a, T> Extend<Pair<'a, T>> for Punctuated<'a, T>
[src]
pub fn extend<I: IntoIterator<Item = Pair<'a, T>>>(&mut self, iter: I)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<'a, T> FromIterator<Pair<'a, T>> for Punctuated<'a, T>
[src]
pub fn from_iter<I: IntoIterator<Item = Pair<'a, T>>>(iter: I) -> Self
[src]
impl<'a, T: Node<'a>> Node<'a> for Pair<'a, T>
[src]
pub fn start_position(&self) -> Option<Position>
[src]
pub fn end_position(&self) -> Option<Position>
[src]
pub fn similar(&self, other: &Self) -> bool
[src]
pub fn tokens<'b>(&'b self) -> Tokens<'a, 'b>ⓘ
[src]
pub fn range(&self) -> Option<(Position, Position)>
[src]
pub fn surrounding_trivia<'b>(
&'b self
) -> (Vec<Cow<'b, Token<'ast>>>, Vec<Cow<'b, Token<'ast>>>)
[src]
&'b self
) -> (Vec<Cow<'b, Token<'ast>>>, Vec<Cow<'b, Token<'ast>>>)
impl<T, '_> Owned for Pair<'_, T> where
T: Owned,
[src]
T: Owned,
type Owned = Pair<'static, <T as Owned>::Owned>
What an owned version of the object looks like. Usually contains a 'static
lifetime.
pub fn owned(&self) -> Self::Owned
[src]
impl<'a, T: PartialEq> PartialEq<Pair<'a, T>> for Pair<'a, T>
[src]
pub fn eq(&self, other: &Pair<'a, T>) -> bool
[src]
pub fn ne(&self, other: &Pair<'a, T>) -> bool
[src]
impl<'a, T> Serialize for Pair<'a, T> where
T: Serialize,
[src]
T: Serialize,
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'a, T> StructuralPartialEq for Pair<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for Pair<'a, T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<'a, T> Send for Pair<'a, T> where
T: Send,
[src]
T: Send,
impl<'a, T> Sync for Pair<'a, T> where
T: Sync,
[src]
T: Sync,
impl<'a, T> Unpin for Pair<'a, T> where
T: Unpin,
[src]
T: Unpin,
impl<'a, T> UnwindSafe for Pair<'a, T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,