'Double dereference operator on self in Deref trait implementation for Box [duplicate]
Looking at implementation of Deref
trait for Box
:
impl<T: ?Sized, A: Allocator> const Deref for Box<T, A> {
type Target = T;
fn deref(&self) -> &T {
&**self
}
}
i cannot understand double use of dereference operator *
on self
. By implementing Deref
trait that way on a custom type, obviously the compiler complains about a recursive call. I'm missing something...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|