2

我试图在我的运行时同时使用 Assets 模块和 Balances 模块。他们都导出了 Trait T::Balance。当我将 Assets 模块带入我的特征范围时,如下所示:

pub trait Trait: assets::Trait + balances::Trait {}

我收到以下错误:

error[E0221]: ambiguous associated type `Balance` in bounds of `T`
   --> /home/volt/workspaces/lsaether/vyzer/runtime/src/markets.rs:124:42
    |
124 |         ValidityBond get(validity_bond): T::Balance;
    |                                          ^^^^^^^^^^ ambiguous associated type `Balance`
    |
note: associated type `T` could derive from `srml_assets::Trait`
   --> /home/volt/workspaces/lsaether/vyzer/runtime/src/markets.rs:124:42
    |
124 |         ValidityBond get(validity_bond): T::Balance;
    |                                          ^^^^^^^^^^
note: associated type `T` could derive from `srml_balances::Trait`
   --> /home/volt/workspaces/lsaether/vyzer/runtime/src/markets.rs:124:42
    |
124 |         ValidityBond get(validity_bond): T::Balance;
    |                                          ^^^^^^^^^^

4

1 回答 1

4

而不是T::Balance在这里使用,您需要更具体地针对 Rust 编译器。

您可以执行<T as balances::Trait>::Balance<T as assets::Trait>::Balance指定您实际想要使用的“平衡”。

让我知道这是否有帮助!

于 2019-07-20T12:02:27.180 回答