daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct MutRefVec<T> {
  2.     vec:Vec<*mut T>,
  3. }
  4.  
  5. impl<T> MutRefVec<T> {
  6.     pub fn new() -> Self {
  7.         MutRefVec { vec:Vec::new() }
  8.     }
  9.  
  10.     pub fn push(&mut self, x:&mut T) {
  11.         self.vec.push(x as *mut T)
  12.     }
  13.  
  14.     pub fn get(&mut self, i:usize) -> &mut T {
  15.         unsafe { &mut *self.vec[i] }
  16.     }
  17. }
  18.  
  19. fn main() {}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top