hanks for your fast answer.
I've made some test and if I remove mod actions; in testaction.rs I have the error: unresolved name impl actions::Action for TestAction in testaction.rs If I remove the mod actions; and keep the mod testaction; in the test.rs I have unresolved name in the line let actelm: ~actions::Action = element as ~actions::Action; for actions::Action.

I don't see what to do!!

I didn't fully understand the module management but even if I made something wrong rustc in my opinion shouldn't load the same module twice and if a module is load once it should use it for all. It make me think about I#ifndef in C.

Philippe Delrieu


Le 08/11/2013 09:53, Alex Crichton a écrit :
You should be careful to declare modules only once. It looks like you
have two instances of "mod actions" in the module hierarchy, and both
modules will be compiled as separate entities (although everything
will have the same name).

If you remove the `mod actions` inside of testaction.rs you should
start making some more progress. You'll probably hit some name
resolution issues, but just be sure to import the previous declaration
of the `actions` module in the top level of the crate.

On Thu, Nov 7, 2013 at 11:50 PM, Philippe Delrieu
<[email protected]> wrote:
Hello, rust addict.

I have a problem with rustc. I have 3 files.
The first one actions.rs contains a trait declaration :

pub trait Action {
     // process the action on server side.
     fn process(&self) -> ~str;
}

The second contains a trait implementation testaction.rs:
mod actions;


pub struct TestAction    {
     actiontype: uint
}

impl actions::Action for TestAction    {

     fn process(&self) -> ~str     {
         ~""
     }
}
  The third test the trait cast :
     mod actions;
     mod midi;

                 let element : ~testaction::TestAction =
~testaction::TestAction{actiontype:1};
                 let actelm: ~actions::Action = element as ~actions::Action;
//error here
                 println("process element :" + actelm.process());
=> generate  error: failed to find an implementation of trait

                 let actelm: ~testaction::actions::Action = element as
~testaction::actions::Action;  //error here
                 println("process element :" + actelm.process());
=> generate error: trait `Action` is inaccessible

If I put testaction content in the test file rustc compile.

Any idea?

Philippe Delrieu


_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev


_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to