E0079#
Warning name: implicit_impl_as_method
Methods from an impl Trait for Type declaration are being attached to Type
implicitly. This compatibility behavior is deprecated because it is not
explicit or refactoring-safe. The warning is disabled by default in v0.10.4.
Erroneous example#
///|
pub(open) trait Render {
fn render(Self) -> String
}
///|
pub(all) struct Badge(String)
///|
pub impl Render for Badge with render(self) {
self.0
}
///|
pub fn show_badge(badge : Badge) -> String {
badge.render()
}
Suggestion#
Use extend Type with Trait::{method} for methods that should support dot
syntax. Otherwise, call the implementation as Trait::method(value).
///|
pub(open) trait Render {
fn render(Self) -> String
}
///|
pub(all) struct Badge(String)
///|
pub impl Render for Badge with render(self) {
self.0
}
///|
pub extend Badge with Render::{render}
///|
pub fn show_badge(badge : Badge) -> String {
badge.render()
}