Repository: jaemk/cached (language: rust)

Issue:
Can we get rid of the std::mem::replace warning?
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


Discussion / hints:

Fix patch:
diff --git a/src/stores.rs b/src/stores.rs
index 2b514c2..5d68e83 100644
--- a/src/stores.rs
+++ b/src/stores.rs
@@ -627,7 +627,7 @@ impl<K: Hash + Eq, V> Cached<K, V> for HashMap<K, V> {
         self.clear();
     }
     fn cache_reset(&mut self) {
-        std::mem::replace(self, HashMap::new());
+        *self = HashMap::new();
     }
     fn cache_size(&self) -> usize {
         self.len()


Test patch: