jessica reading problem

use std::collections::BTreeMap;
use std::cmp;

const P: i32 = 5;
const a: [i32; 5] = [1, 8, 8, 8, 1];

fn main() {
   let mut all: Vec<i32> = Vec::new();
   for i in 0.. {
      if !(i < P) {
         break;
      }
      if !all.contains(&a[i as usize]) {
         all.push(a[i as usize]);
      }
   }
   let n = all.len();

   let s = 0;
   let t = 0;
   let num = 0;

   let mut count = BTreeMap::new();
   let res = P;

   loop {
      while ( t < P && num < n) {
         if(count[a[t++]]++ == 0) {
            num += 1;
         }
      }
      if (num < n) {
         break;
      }
      res = cmp::min(res, t - s);
      if (--count[a[s++]] == 0) {
         num --;
      }
   }
   println!("{}", res);

}