How to eliminate related types within the boundaries of object objects?

If I try to define a box field IEvent, for example:

use stdweb::private::ConversionError;
use stdweb::web::event::IEvent;

struct Foo {
    bar: Box<IEvent<Error = ConversionError>>,
}

I get an error message:

error[E0221]: ambiguous associated type `Error` in bounds of `stdweb::traits::IEvent`
  --> src/events.rs:16:21
   |
16 |     bar: Box<IEvent<Error = ConversionError>>,
   |                     ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type `Error`
   |
note: associated type `stdweb::traits::IEvent` could derive from `stdweb::unstable::TryFrom<stdweb::Reference>`
  --> src/events.rs:16:21
   |
16 |     bar: Box<IEvent<Error = ConversionError>>,
   |                     ^^^^^^^^^^^^^^^^^^^^^^^
note: associated type `stdweb::traits::IEvent` could derive from `stdweb::unstable::TryFrom<stdweb::Value>`
  --> src/events.rs:16:21
   |
16 |     bar: Box<IEvent<Error = ConversionError>>,
   |                     ^^^^^^^^^^^^^^^^^^^^^^^

If you want more information on this error, try using "rustc --explain E0221"

How to write syntax for setting related types Error(for signs TryFrom<Value>and TryFrom<Reference>)?

+4
source share
1 answer

I do not believe that you can.

Studying what I consider to be the appropriate type in the compiler ( TypeBindingclibsyntax ) shows that it only supports a single identifier for the associated type. Therefore, I do not think that there is a way to specify related types from a field type.

, . stdweb , TryFrom::Error , , ReferenceType, , . ReferenceType , Error, .

, , . - , .

, , stdweb, TryFrom.

+4

Source: https://habr.com/ru/post/1694561/


All Articles