Skip to content

Commit

Permalink
fix: session inspection panics
Browse files Browse the repository at this point in the history
  • Loading branch information
Banyc committed Oct 28, 2023
1 parent 8381ecf commit e543c0d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions common/src/session_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct SessionGuard<'table, T> {
}

impl<T> SessionGuard<'_, T> {
pub fn inspect_mut<O>(&self, f: fn(&mut T) -> O) -> O {
pub fn inspect_mut(&self, f: fn(&mut T)) {
inspect_mut(self.table, self.key, f)
}
}
Expand All @@ -102,7 +102,7 @@ pub struct SessionOwnedGuard<T> {
}

impl<T> SessionOwnedGuard<T> {
pub fn inspect_mut<O>(&self, f: fn(&mut T) -> O) -> O {
pub fn inspect_mut(&self, f: fn(&mut T)) {
inspect_mut(&self.table, self.key, f)
}
}
Expand All @@ -113,9 +113,11 @@ impl<T> Drop for SessionOwnedGuard<T> {
}
}

fn inspect_mut<T, O>(table: &SessionTable<T>, key: SessionKey, f: fn(&mut T) -> O) -> O {
fn inspect_mut<T>(table: &SessionTable<T>, key: SessionKey, f: fn(&mut T)) {
let mut map = table.map.write().unwrap();
let session = map.get_mut(key).unwrap();
let Some(session) = map.get_mut(key) else {
return;
};
f(session)
}

Expand Down

0 comments on commit e543c0d

Please sign in to comment.