From 11ec7c078896d3963969f55c40aff5042f693025 Mon Sep 17 00:00:00 2001 From: Nixon <43715558+nixonyh@users.noreply.github.com> Date: Fri, 5 Jun 2026 23:39:46 +0800 Subject: [PATCH] Hot fix scope not checking key generation --- src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d70ab41..58c393b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -195,6 +195,11 @@ impl SparseMap { where F: FnOnce(&mut Self, &mut T) -> R, { + let generation = self.generations.get(key.index)?; + if *generation != key.generation { + return None; + } + let mut value = self.buffer[key.index].take()?; let result = f(self, &mut value); self.buffer[key.index] = Some(value);