Struct rune::ast::Parenthesized[][src]

pub struct Parenthesized<T, S> {
    pub open: OpenParen,
    pub parenthesized: Vec<(T, Option<S>)>,
    pub close: CloseParen,
}

Parse something parenthesis, that is separated by ((T, S?)*).

Examples

use rune::{T, testing, ast};

testing::roundtrip::<ast::Parenthesized<ast::Expr, T![,]>>("(1, \"two\")");
testing::roundtrip::<ast::Parenthesized<ast::Expr, T![,]>>("(1, 2,)");
testing::roundtrip::<ast::Parenthesized<ast::Expr, T![,]>>("(1, 2, foo())");

Fields

open: OpenParen

The open parenthesis.

parenthesized: Vec<(T, Option<S>)>

Values in the type.

close: CloseParen

The close parenthesis.

Implementations

impl<T, S> Parenthesized<T, S>[src]

pub fn is_empty(&self) -> bool[src]

Test if empty.

pub fn len(&self) -> usize[src]

Get the length of the parsed elements.

pub fn first(&self) -> Option<&(T, Option<S>)>[src]

Get the first element.

pub fn last(&self) -> Option<&(T, Option<S>)>[src]

Get the last element.

pub fn iter(&self) -> Iter<'_, (T, Option<S>)>[src]

Iterate over elements.

pub fn iter_mut(&mut self) -> IterMut<'_, (T, Option<S>)>[src]

Iterate mutably over elements.

pub fn as_slice(&self) -> &[(T, Option<S>)][src]

Get the values as a slice.

impl<T, S> Parenthesized<T, S> where
    T: Parse,
    S: Peek + Parse
[src]

pub fn parse_from_first(
    parser: &mut Parser<'_>,
    open: OpenParen,
    current: T
) -> Result<Self, ParseError>
[src]

Parse with the first element already specified.

Trait Implementations

impl<T: Clone, S: Clone> Clone for Parenthesized<T, S>[src]

impl<T: Debug, S: Debug> Debug for Parenthesized<T, S>[src]

impl<T: Eq, S: Eq> Eq for Parenthesized<T, S>[src]

impl<'a, T, S> IntoIterator for &'a Parenthesized<T, S>[src]

type Item = &'a (T, Option<S>)

The type of the elements being iterated over.

type IntoIter = Iter<'a, (T, Option<S>)>

Which kind of iterator are we turning this into?

impl<'a, T, S> IntoIterator for &'a mut Parenthesized<T, S>[src]

type Item = &'a mut (T, Option<S>)

The type of the elements being iterated over.

type IntoIter = IterMut<'a, (T, Option<S>)>

Which kind of iterator are we turning this into?

impl<T, S> IntoIterator for Parenthesized<T, S>[src]

type Item = (T, Option<S>)

The type of the elements being iterated over.

type IntoIter = IntoIter<(T, Option<S>)>

Which kind of iterator are we turning this into?

impl<T, S> Parse for Parenthesized<T, S> where
    T: Parse,
    S: Peek + Parse
[src]

impl<T: PartialEq, S: PartialEq> PartialEq<Parenthesized<T, S>> for Parenthesized<T, S>[src]

impl<T, S> Peek for Parenthesized<T, S>[src]

impl<T, S> Spanned for Parenthesized<T, S>[src]

impl<T, S> StructuralEq for Parenthesized<T, S>[src]

impl<T, S> StructuralPartialEq for Parenthesized<T, S>[src]

impl<T, S> ToTokens for Parenthesized<T, S> where
    T: ToTokens,
    S: ToTokens
[src]

Auto Trait Implementations

impl<T, S> RefUnwindSafe for Parenthesized<T, S> where
    S: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, S> Send for Parenthesized<T, S> where
    S: Send,
    T: Send

impl<T, S> Sync for Parenthesized<T, S> where
    S: Sync,
    T: Sync

impl<T, S> Unpin for Parenthesized<T, S> where
    S: Unpin,
    T: Unpin

impl<T, S> UnwindSafe for Parenthesized<T, S> where
    S: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.