Think about clone()
Before Using It
Source: https://rust-unofficial.github.io/patterns/anti_patterns/borrow_clone.html
It is easy to satisfy the compiler by calling clone()
. However, it is important to understand what
it means before doing it. It creates a separate variable, which means that making a change to the
cloned value does not change the original value. Also, there is a cost of doing it, which may or may
not be cheap. Thus, before using clone()
, it is important to think through first. This does
not mean that