traitcast icon indicating copy to clipboard operation
traitcast copied to clipboard

Bug: use of undeclared type or module `inventory`

Open SiebenCorgie opened this issue 5 years ago • 1 comments

Hi,

I tried to used the crate like this:

extern crate traitcast;
use traitcast::{TraitcastFrom, Traitcast};

pub trait Widget: TraitcastFrom{
    fn print(&self){
	println!("Yay from the trait!");
    }
}

struct One(u32);
impl One{
    fn print_one(&self){
	println!("From within one: {}", self.0);
    }
}
impl Widget for One{}


struct Two(f32);
impl Two{
    fn print_two(&self){
	println!("From within two: {}", self.0);
    }
}
impl Widget for Two{}


traitcast::traitcast!(struct One: Widget);
traitcast::traitcast!(struct Two: Widget);

However, the compiler notes for the traitcast! lines:

error[E0433]: failed to resolve: use of undeclared type or module `inventory`
   --> neith-synth/src/main.rs:100:1
    |
100 | traitcast::traitcast!(struct Two: Widget);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type or module `inventory`
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Any idea why this might happen? I also tried version 0.2.1, but it does not work as well.

SiebenCorgie avatar Mar 21 '20 23:03 SiebenCorgie

This crate doesn't seem to be in active maintenance. If it's ok to switch to another similar crate, I wrote a new crate called intertrait basically motivated by traitcast. Since I have a main project to use it, it will be actively maintained (actually planning to enhance).

https://github.com/codechain-io/intertrait

dynaxis avatar Apr 03 '20 14:04 dynaxis