这是在声明
supertrait
. 相当于:
trait Enchanter
where
Self: std::fmt::Debug,
{
}
简而言之,它需要任何想要实现的类型
Enchanter
也要实施
std::fmt::Debug
. 否则
an error will be raised
:
error[E0277]: `S` doesn't implement `Debug`
--> src/lib.rs:4:6
|
4 | impl Enchanter for S {}
| ^^^^^^^^^ `S` cannot be formatted using `{:?}`
|
= help: the trait `Debug` is not implemented for `S`
= note: add `#[derive(Debug)]` to `S` or manually `impl Debug for S`
note: required by a bound in `Enchanter`
--> src/lib.rs:1:18
|
1 | trait Enchanter: std::fmt::Debug {}
| ^^^^^^^^^^^^^^^ required by this bound in `Enchanter`