Trying to implement the Debug
trait for a custom type I stumbled upon the implementation for Vec<T>
. I have difficulties understanding how it works.
The implementation goes like this:
impl<T: fmt::Debug> fmt::Debug for Vec<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
}
}
I understand it calls the fmt
implementation for some other type. What I cannot understand is what type it is. I've tried to figure it out with the help of another question, and searching among the implementations of Debug
for something that looks appropriate (maybe something like &[T]
), but with no success.
What is the exact meaning of &**self
in this context? What implementation of Debug
is being called?