如果我有以下类似的特征Foo
:
trait Foo: Bar {
type Account: SomeTrait;
}
这里有一个需要 Bar
的 trait bound。
trait Bar {
type UserId;
}
我如何在
Foo
特性中请求,要求Bar
特性内的UserId
类型为u32
?重要提示:我不能编辑
Bar
特性。如果我有以下类似的特征Foo
:
trait Foo: Bar {
type Account: SomeTrait;
}
这里有一个需要 Bar
的 trait bound。
trait Bar {
type UserId;
}
Foo
特性中请求,要求Bar
特性内的UserId
类型为u32
?Bar
特性。
trait Bar<T> { ... }
允许您编写trait Foo: Bar<u32> { ... }
。 - BitTicklertrait NarrowedBar<T>: Bar { UserId = T; }
的东西。 - BitTickler