Skip to main content

impl_variant_param

Macro impl_variant_param 

Source
macro_rules! impl_variant_param {
    ($ty:ty, $cat:expr) => { ... };
    ($ty:ty, $cat:expr, parent: $parent:ty, cast: $cast:expr) => { ... };
    ($ty:ty, $cat:expr, k: $k:expr) => { ... };
    ($ty:ty, $cat:expr, parent: $parent:ty, cast: $cast:expr, k: $k:expr) => { ... };
}
Expand description

Implement VariantParam (and optionally CastToParent and/or KValue) for a type.

ยงUsage

// Root type (no parent):
impl_variant_param!(SimpleGraph, "graph");

// Type with parent -- cast closure required:
impl_variant_param!(UnitDiskGraph, "graph", parent: SimpleGraph,
    cast: |g| SimpleGraph::new(g.num_vertices(), g.edges()));

// Root K type (no parent, with K value):
impl_variant_param!(KN, "k", k: None);

// K type with parent + cast + K value:
impl_variant_param!(K3, "k", parent: KN, cast: |_| KN, k: Some(3));