everyone, I am a beginner of rust,and I have read the rust book and rust reference.I am confused about which condition that rust compiler automatic Deref or Ref when using a method call. for example:sometimes when call the method like value.methond1()
where value is type of T
and T
implement the method1,then value will be auto Deref
or Ref
.can anyone give me a summary conclusion about rust auto Deref
and Ref
Asked
Active
Viewed 40 times
0

Kishan Mevada
- 662
- 1
- 6
- 17

liulu17
- 21
- 1
-
1See also [the tldr provided by shepmaster](https://stackoverflow.com/questions/36426207/why-does-rust-not-deref-string-to-str?noredirect=1&lq=1#comment60472747_36426207): the compiler will deref' (apply the `*` operator) any number of times, and ref' (apply the `&` operator) *at most once*. – Masklinn Sep 06 '22 at 06:40