aboutsummaryrefslogtreecommitdiff
path: root/src/data
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-05-25 11:00:13 +0200
committerCrozet Sébastien <developer@crozet.re>2021-05-25 11:00:13 +0200
commit1bef66fea941307a7305ddaebdb0abe3d0cb281f (patch)
tree450bc3cd2fd611f91cb7d7809edcc4260f043b0b /src/data
parent47139323e01f978a94ed7aa2c33bbf63b00f4c30 (diff)
downloadrapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.tar.gz
rapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.tar.bz2
rapier-1bef66fea941307a7305ddaebdb0abe3d0cb281f.zip
Add prelude + use vectors for setting linvel/translation in builders
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();