(&self, key: &UserKey)
| 77 | } |
| 78 | |
| 79 | fn remove(&self, key: &UserKey) -> Option<User> { |
| 80 | DB.with(|m| { |
| 81 | let prev = m.borrow_mut().remove(key); |
| 82 | |
| 83 | // Update metrics when a user is removed. |
| 84 | if let Some(prev) = &prev { |
| 85 | USER_METRICS.with(|metrics| { |
| 86 | metrics |
| 87 | .iter() |
| 88 | .for_each(|metric| metric.borrow_mut().sub(prev)) |
| 89 | }); |
| 90 | |
| 91 | self.remove_entry_indexes(prev); |
| 92 | } |
| 93 | |
| 94 | prev |
| 95 | }) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | impl UserRepository { |