I believe there is a mistake in the sample code in the https://brson.github.io/rust-anthology/1/rust-reuse-and-recycle.html.
self in the following snippet, is type Generic<T> so must reference the data therein:
// Incorrect
// Implementing a generic trait for a generic type generically.
// Note that we have two generic types in play; T and U.
impl<T: Equal<U>, U> Equal<Generic<U>> for Generic<T> {
fn equal(&self, other: &Generic<U>) -> bool {
self.equal(&other.data) // <<< should be self.data.equal(&other.data)
}
}
// correct
impl<T: Equal<U>, U> Equal<Generic<U>> for Generic<T> {
fn equal(&self, other: &Generic<U>) -> bool {
self.data.equal(&other.data)
}
}
I believe there is a mistake in the sample code in the https://brson.github.io/rust-anthology/1/rust-reuse-and-recycle.html.
selfin the following snippet, is typeGeneric<T>so must reference thedatatherein: