Trait Pair

Source
pub trait Pair {
    type Open<'source>: Parse<'source>;
    type Close<'source>: Parse<'source>;

    const OPEN: TokenKind;
    const CLOSE: TokenKind;
}
Expand description

A trait for token kinds that have a logical pairing with another token kind. Only tokens that implement Pair can be used with the Surrounded helper.

This includes tokens like parentheses, square brackets, and curly braces.

Required Associated Constants§

Source

const OPEN: TokenKind

The corresponding opening TokenKind.

Source

const CLOSE: TokenKind

The corresponding closing TokenKind.

Required Associated Types§

Source

type Open<'source>: Parse<'source>

The type of the opening token, defined in the token module.

Source

type Close<'source>: Parse<'source>

The type of the closing token, defined in the token module.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Pair for CloseCurly<'_>

Source§

const OPEN: TokenKind = TokenKind::OpenCurly

Source§

const CLOSE: TokenKind = TokenKind::CloseCurly

Source§

type Open<'source> = OpenCurly<'source>

Source§

type Close<'source> = CloseCurly<'source>

Source§

impl Pair for CloseParen<'_>

Source§

const OPEN: TokenKind = TokenKind::OpenParen

Source§

const CLOSE: TokenKind = TokenKind::CloseParen

Source§

type Open<'source> = OpenParen<'source>

Source§

type Close<'source> = CloseParen<'source>

Source§

impl Pair for CloseSquare<'_>

Source§

const OPEN: TokenKind = TokenKind::OpenSquare

Source§

const CLOSE: TokenKind = TokenKind::CloseSquare

Source§

type Open<'source> = OpenSquare<'source>

Source§

type Close<'source> = CloseSquare<'source>

Source§

impl Pair for OpenCurly<'_>

Source§

const OPEN: TokenKind = TokenKind::OpenCurly

Source§

const CLOSE: TokenKind = TokenKind::CloseCurly

Source§

type Open<'source> = OpenCurly<'source>

Source§

type Close<'source> = CloseCurly<'source>

Source§

impl Pair for OpenParen<'_>

Source§

const OPEN: TokenKind = TokenKind::OpenParen

Source§

const CLOSE: TokenKind = TokenKind::CloseParen

Source§

type Open<'source> = OpenParen<'source>

Source§

type Close<'source> = CloseParen<'source>

Source§

impl Pair for OpenSquare<'_>

Source§

const OPEN: TokenKind = TokenKind::OpenSquare

Source§

const CLOSE: TokenKind = TokenKind::CloseSquare

Source§

type Open<'source> = OpenSquare<'source>

Source§

type Close<'source> = CloseSquare<'source>