heapのpushとpop

fn push(x: i32) {
   let mut heap = [1, 2, 3, 4, 5, 6, 7, 8];
   let sz = 0;
   let mut i = sz + 1;

   while(i > 0) {
      let p = (i -1) / 2;

      if heap[p] <= x {
         break;
      }

      heap[i] = heap[p];
      i = p;
   }
   heap[i] = x;
}

fn pop() {
   let mut heap = [1, 2, 3, 4, 5, 6, 7, 8];
   let sz = 0;

   let ret = heap[0];
   let x = heap[heap.len() -1];

   let mut i = 0;
   while(i * 2 + 1 < sz) {
      let mut a = i * 2 + 1;
      let mut b = i * 2 + 2;
      if (b < sz && heap[b] < heap[a]) {
         a = b;
      }
      if (heap[a] >= x) {
         break;
      }

      heap[i] = heap[a];
      i = a;
   }
   heap[i] = x;
}