如何重新导出枚举?

时间:2015-08-13 00:49:30

标签: module rust

这给了我一个错误:

mod foo {
  pub enum T {
    Foo,
  }
}

mod bar {
  pub type T = ::foo::T;
}

fn main() {
  let _ = bar::T::Foo; // error: no associated item named `Foo` found for type `foo::T` in the current scope
}

这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:5)

这是一个已知问题,#26264

您应该pub use foo::T;type纯粹是一个别名,其意图是类型的组合和填充泛型(例如type Foo = Bar<Baz>;),因此对于公共再出口,它无论如何都不会做你想要的。

相关问题