syntree

Macro flavor

Source
macro_rules! flavor {
    (
        $(#[doc = $doc:literal])*
        $vis:vis struct $ty:ident {
            type Index = $index:ty;
            $(type Width = $width:ty;)?
            $(type Storage = $storage:ty;)?
            $(type Indexes = $indexes:ty;)?
        }
    ) => { ... };
    (@width $ty:ty) => { ... };
    (@width) => { ... };
    (@pointer $ty:ty) => { ... };
    (@pointer) => { ... };
    (@indexes $ty:ty) => { ... };
    (@indexes) => { ... };
}
Expand description

Declare a new flavor.

The available type parameters are:

  • type Index which declares the index to use.
  • type Width which declares the width to use, defaults to usize.

ยงExamples

use syntree::{Empty, EmptyVec, TreeIndex};

syntree::flavor! {
    struct FlavorEmpty {
        type Index = Empty;
        type Indexes = EmptyVec<TreeIndex<Self>>;
    }
}

syntree::flavor! {
    struct FlavorU32 {
        type Index = u32;
        type Width = u32;
    }
}