如何消除具有相同名称的特征之间的歧义?
How to disambiguate between traits with the same name?
我正在尝试在运行时同时使用资产模块和余额模块。他们都导出了 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;
| ^^^^^^^^^^
而不是在这里使用 T::Balance
,您需要更具体地了解 Rust 编译器。
您可以执行 <T as balances::Trait>::Balance
或 <T as assets::Trait>::Balance
来指定您实际想要使用的 "Balance"。
如果有帮助请告诉我!
我正在尝试在运行时同时使用资产模块和余额模块。他们都导出了 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;
| ^^^^^^^^^^
而不是在这里使用 T::Balance
,您需要更具体地了解 Rust 编译器。
您可以执行 <T as balances::Trait>::Balance
或 <T as assets::Trait>::Balance
来指定您实际想要使用的 "Balance"。
如果有帮助请告诉我!