Should I used .clone() or to solve a problem or not ?? It also says if the performance cost is acceptable

61 points Aromatic_Road_9167 56 comments

I'm new to rust and sometime it suggests, add .clone() and I just correct it asap. However, Today I can see it also says if the performance cost is acceptable.. How much performance we are talking about ????

error[E0382]: borrow of moved value: `tier`
   --> src/handlers/auth.rs:896:56
    |
760 |     let (email, tier) = {
    |                 ---- move occurs because `tier` has type `std::string::String`, which does not implement the `Copy` trait
...
894 |         tier,
    |         ---- value moved here
895 |         lauda: payload.lauda.clone(),
896 |         waitlist_position: calculate_waitlist_position(&tier),
    |                                                        ^^^^^ value borrowed here after move
    |
    = note: borrow occurs due to deref coercion to `str`
help: consider cloning the value if the performance cost is acceptable
    |
894 |         tier: tier.clone(),