[][src]Enum genco::tokens::Item

pub enum Item<L> where
    L: Lang
{ Literal(ItemStr), Lang(Box<dyn LangItem<L>>), Register(Box<dyn LangItem<L>>), Push, Line, Space, Indentation(i16), OpenQuote(bool), CloseQuote, OpenEval, CloseEval, }

A single item in a stream of tokens.

Variants

Literal(ItemStr)

A literal item. Is added as a raw string to the stream of tokens.

Lang(Box<dyn LangItem<L>>)

A language-specific boxed item.

Register(Box<dyn LangItem<L>>)

A language-specific boxed item that is not rendered.

Push

Push a new line unless the current line is empty. Will be flushed on indentation changes.

Line

Push a line. Will be flushed on indentation changes.

Space

Space between language items. Typically a single space.

Multiple spacings in sequence are collapsed into one. A spacing does nothing if at the beginning of a line.

Indentation(i16)

Manage indentation.

An indentation of 0 has no effect.

OpenQuote(bool)

Switch to handling input as a quote.

The argument indicates whether the string contains any interpolated values.

The string content is quoted with the language-specific [quoting method]. [quoting method]: Lang::Openquote_string

CloseQuote

Close the current quote.

OpenEval

Switch on evaluation. Only valid during string handling.

CloseEval

Close evaluation.

Trait Implementations

impl<L> Clone for Item<L> where
    L: Lang
[src]

impl<L> Debug for Item<L> where
    L: Lang
[src]

impl<L> Eq for Item<L> where
    L: Lang
[src]

impl<L> FormatInto<L> for Item<L> where
    L: Lang
[src]

Formatting an item is the same as adding said item to the token stream through item().

Examples

use genco::prelude::*;
use genco::tokens::{Item, ItemStr};

let foo = Item::Literal(ItemStr::Static("foo"));
let bar = Item::Literal(ItemStr::Box("bar".into()));

let result: Tokens = quote!(#foo #bar baz);

assert_eq!("foo bar baz", result.to_string()?);

assert_eq!{
    vec![
        Item::Literal(ItemStr::Static("foo")),
        Item::Space,
        Item::Literal(ItemStr::Box("bar".into())),
        Item::Space,
        Item::Literal(ItemStr::Static("baz")),
    ] as Vec<Item<()>>,
    result,
};

impl<'a, L> FromIterator<&'a Item<L>> for Tokens<L> where
    L: Lang
[src]

impl<L> FromIterator<Item<L>> for Tokens<L> where
    L: Lang
[src]

impl<L> PartialEq<Item<L>> for Item<L> where
    L: Lang
[src]

Auto Trait Implementations

impl<L> !RefUnwindSafe for Item<L>

impl<L> !Send for Item<L>

impl<L> !Sync for Item<L>

impl<L> Unpin for Item<L>

impl<L> !UnwindSafe for Item<L>

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.