1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
use std::marker::PhantomData; use crate::ffi; use crate::joint::Joint; use crate::newton::Newton; #[derive(Debug)] pub struct Contacts<'a> { _phantom: PhantomData<&'a ()>, } #[derive(Debug)] pub struct Joints<'a> { pub(crate) joint: *const ffi::NewtonJoint, pub(crate) body: *const ffi::NewtonBody, pub(crate) _phantom: PhantomData<&'a ()>, } impl<'a> Iterator for Joints<'a> { type Item = Joint<'a>; fn next(&mut self) -> Option<Self::Item> { let current = self.joint; if current.is_null() { None } else { unsafe { let next = ffi::NewtonBodyGetNextJoint(self.body, current); self.joint = next; Some(Joint::from_raw(current, false)) } } } }