aboutsummaryrefslogtreecommitdiff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/coarena.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/data/coarena.rs b/src/data/coarena.rs
index cd64910..ac6e43f 100644
--- a/src/data/coarena.rs
+++ b/src/data/coarena.rs
@@ -13,6 +13,14 @@ impl<T> Coarena<T> {
Self { data: Vec::new() }
}
+ /// Gets a specific element from the coarena without specifying its generation number.
+ ///
+ /// It is strongly encouraged to use `Coarena::get` instead of this method because this method
+ /// can suffer from the ABA problem.
+ pub fn get_unknown_gen(&self, index: u32) -> Option<&T> {
+ self.data.get(index as usize).map(|(_, t)| t)
+ }
+
/// Gets a specific element from the coarena, if it exists.
pub fn get(&self, index: Index) -> Option<&T> {
let (i, g) = index.into_raw_parts();