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:
Using:
inventoryversion0.1.3(have^0.1defined in my manifest)rustc 1.34.0-nightly (b139669f3 2019-02-06)cargo 1.34.0-nightly (4e74e2fc0 2019-02-02)main.rs
commands/mod.rs
Output is as follows: