Enum full_moon::ast::punctuated::Pair[][src]

pub enum Pair<'a, T> {
    End(T),
    Punctuated(T, TokenReference<'a>),
}
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>)

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);

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (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

The tokens surrounding a node that are ignored and not accessible through the node’s own accessors. Use this if you want to get surrounding comments or whitespace. Returns a tuple of the leading and trailing trivia. Read more

What an owned version of the object looks like. Usually contains a 'static lifetime.

Returns an owned version of the object.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.