From 1bef66fea941307a7305ddaebdb0abe3d0cb281f Mon Sep 17 00:00:00 2001 From: Crozet Sébastien Date: Tue, 25 May 2021 11:00:13 +0200 Subject: Add prelude + use vectors for setting linvel/translation in builders --- src/data/coarena.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/data') 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 Coarena { 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(); -- cgit