macro_rules! collect {
    ($ty:ty) => { ... };
}
Expand description

Associate a plugin registry with the specified type.

This call must be in the same crate that defines the plugin type. This macro does not “run” anything so place it outside of any function body.

Examples

Suppose we are writing a command line flags library and want to allow any source file in the application to register command line flags that are relevant to it.

This is the flag registration style used by gflags and is better suited for large scale development than maintaining a single central list of flags, as the central list would become an endless source of merge conflicts.

pub struct Flag {
    short: char,
    name: &'static str,
    /* ... */
}

inventory::collect!(Flag);

Refer to the crate level documentation for a complete example of submitting plugins and iterating a plugin registry.