# inventory::collect - Rust
Associate a plugin registry with the specified type.
Keywords: rust, rustlang, rust-lang, collect

# Macro inventory::collect [−] [src]

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

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.