小编Unb*_*T26的帖子

特征上的关联类型默认值

当我们需要一个依赖于特征中其他类型的类型时,我们如何克服关联类型默认值的问题?

    trait Foo{
        type C;
        type K = Vec<Self::C>;
    }
Run Code Online (Sandbox Code Playgroud)
error[E0658]: associated type defaults are unstable
  |
3 |     type K = Vec<Self::C>;
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
   = note: see issue #29661 <https://github.com/rust-lang/rust/issues/29661> for more information
Run Code Online (Sandbox Code Playgroud)

types traits rust

6
推荐指数
1
解决办法
4101
查看次数

标签 统计

rust ×1

traits ×1

types ×1