jaemk / cached

Rust cache structures and easy function memoization
MIT License
1.58k stars 95 forks source link

Can we get rid of the std::mem::replace warning? #52

Closed drwilco closed 4 years ago

drwilco commented 4 years ago

My compiler keeps complaining about:

https://github.com/jaemk/cached/blob/21bd5c68a3b5aaab3aa63cb2a7b16bdc841a20e4/src/stores.rs#L630

warning: unused return value of `std::mem::replace` that must be used
   --> src/stores.rs:630:9
    |
630 |         std::mem::replace(self, HashMap::new());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unused_must_use)]` on by default
    = note: if you don't need the old value, you can just assign the new value directly

warning: 1 warning emitted

Is there a reason for using std::mem::replace instead of just *self = HashMap::new();?

For convenience, incoming PR

Stargateur commented 4 years ago

None in this case, in my defense it's a new warning or I'm blind.

drwilco commented 4 years ago

It could be new, I'm on 1.45.0. Anyways, PR #53 will get rid of it.