E4010#
pub
is not allowed on default implementation for traits. The default
implementation has the same visibility as the trait itself.
错误示例:#
pub(open) trait Stringer {
stringify(Self) -> String
}
pub impl Stringer with stringify(_self) { "hey" }
In the example above, the pub
keyword is used on the default implementation of
the Stringer
trait, which is not allowed.
建议#
移除 pub
关键字,使默认实现与特性本身具有相同的可见性:
pub(open) trait Stringer {
stringify(Self) -> String
}
impl Stringer with stringify(_self) { "hey" }