[][src]Macro dary_heap::arity

macro_rules! arity {
    ($(#[$attr:meta])* $vis:vis $arity:ident = $num:expr; $($t:tt)*) => { ... };
    () => { ... };
}

Convenience macro to implement Arity for a specific number.

This macro implements Arity for an unconstructable enum. It is a shorthand such that A and B are equivalent in the following:

use dary_heap::{arity, Arity};

arity! { pub A = 3; }

pub enum B {}

impl Arity for B {
    const D: usize = 3;
}

Examples

use dary_heap::{arity, DaryHeap};

arity! { pub D9 = 9; }
pub type NovenaryHeap<T> = DaryHeap<T, D9>;

arity! {
    /// For a denary heap
    D10 = 10;
    /// For an undenary heap
    pub(crate) D11 = 11;
}
type DenaryHeap<T> = DaryHeap<T, D10>;
pub(crate) type UndenaryHeap<T> = DaryHeap<T, D11>;

This macro protects against setting the arity to zero as DaryHeap cannot be used with such an arity. See the relevant section of the Arity trait for more information.

This example deliberately fails to compile
use dary_heap::{arity, DaryHeap};

arity! { D0 = 0; }

let heap = DaryHeap::<_, D0>::from(vec![42]);