Skip to content

Commit

Permalink
fix invalid locations never being dropped (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff committed Jan 3, 2024
1 parent 80a8e1f commit cde5ac5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/generational-box/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,16 @@ impl Owner {
/// Creates an invalid handle. This is useful for creating a handle that will be filled in later. If you use this before the value is filled in, you will get may get a panic or an out of date value.
pub fn invalid<T: 'static>(&self) -> GenerationalBox<T> {
let location = self.store.claim();
GenerationalBox {
let key = GenerationalBox {
raw: location,
#[cfg(any(debug_assertions, feature = "check_generation"))]
generation: location.0.generation.get(),
#[cfg(any(debug_assertions, feature = "debug_ownership"))]
created_at: std::panic::Location::caller(),
_marker: PhantomData,
}
};
self.owned.borrow_mut().push(location);
key
}
}

Expand Down

0 comments on commit cde5ac5

Please sign in to comment.