Skip to content

Does not collect plugins defined outside of crate root #9

@phrohdoh

Description

@phrohdoh

Using:

  • inventory version 0.1.3 (have ^0.1 defined in my manifest)
  • rustc 1.34.0-nightly (b139669f3 2019-02-06)
  • cargo 1.34.0-nightly (4e74e2fc0 2019-02-02)

main.rs

pub mod commands; // added `pub` to see if that would change anything, but it didn't

pub struct Command {
    name: &'static str,
}

impl Command {
    pub fn new(name: &'static str) -> Self {
        Self {
            name,
        }
    }
}

inventory::collect!(Command);

// I tested moving the `mod` to here, after the `collect!`, but no dice

inventory::submit! {
    Command::new("barf")
}

fn main() {
    println!("available commands:");

    for cmd in inventory::iter::<Command> {
        println!("  {}", cmd.name);
    }
}

commands/mod.rs

inventory::submit! {
    crate::Command::new("parse")
}

Output is as follows:

available commands:
  barf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions