[][src]Module dinotree_alg::pmut

Provides a mutable pointer type that is more restrictive that &mut T, in order to protect tree invariants. PMut is short for protected mutable reference.

It prevents the user from violating the invariants of the tree.

extern crate dinotree_alg;
extern crate axgeom;
use dinotree_alg::prelude::*;


let mut bots=[BBox::new(axgeom::Rect::new(0,10,0,10),0)];
let mut tree=DinoTree::new(&mut bots);
 
tree.find_collisions_mut(|mut a,mut b|{
   //We cannot allow the user to swap these two
   //bots. They should be allowed to mutate 
   //whats inside each of them (aside from their aabb),
   //but not swap.
    
   //core::mem::swap(a,b); // We cannot allow this!!!!

   //This is allowed.  
   core::mem::swap(a.inner_mut(),b.inner_mut());
})

Structs

PMut

A protected mutable reference. See the pmut module documentation for more explanation.

PMutIter

Iterator produced by PMut<[T]> that generates PMut<T>