Guest User

Untitled

a guest
Jun 14th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  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() {}
Add Comment
Please, Sign In to add comment