Attribute Macro persian_rug::contextual

source · []
#[contextual]
Expand description

Provide a implementation of Contextual for a type.

This is a very simple derive-style macro, that creates an impl for Contextual for the type it annotates. It takes one argument, which is the Context type that this type belongs to.

Example:

use persian_rug::{contextual, Context};

#[contextual(C)]
struct Foo<C: Context> {
   _marker: core::marker::PhantomData<C>
}

which is equivalent to the following:

use persian_rug::{Context, Contextual};

struct Foo<C: Context> {
   _marker: core::marker::PhantomData<C>
}

impl<C: Context> Contextual for Foo<C> {
   type Context = C;
}