【发布时间】:2018-09-17 13:09:13
【问题描述】:
试图解决Trait bound Sized is not satisfied for Sized trait中描述的问题,我发现以下代码给出了以下错误:
trait SizedTrait: Sized {
fn me() -> Self;
}
trait AnotherTrait: Sized {
fn another_me() -> Self;
}
impl AnotherTrait for SizedTrait + Sized {
fn another_me() {
Self::me()
}
}
error[E0225]: only auto traits can be used as additional traits in a trait object
--> src/main.rs:9:36
|
9 | impl AnotherTrait for SizedTrait + Sized {
| ^^^^^ non-auto additional trait
但是Rust Book 根本没有提到auto trait。
什么是 Rust 中的自动 trait,它与非自动 trait 有何不同?
【问题讨论】:
-
我认为这将是任何自动实现的特征,
Sized肯定是这种情况,但我想知道这是否适用于Send和Sync... -
@MatthieuM。我认为
Sized可能比Send和Sync更特别...
标签: rust