fn min_point(points: &[Vec2], p: Vec2) -> Option<usize> {
  let mut iter = points.iter().enumerate();
  let (id, &p2) = iter.next().unwrap();
  let mut min_dist = city_dist(p, p2);
  let mut min_id = id;
  let mut count = 1usize;
  for (id, &p2) in iter {
    let dist = city_dist(p, p2);
    match dist.cmp(&min_dist) {
      Ordering::Less => {
        min_dist = dist;
        min_id = id;
        count = 1;
      }
      Ordering::Equal => count += 1,
      Ordering::Greater => {}
    }
  }
  (count == 1).then(|| min_id)
}
/// returns the index of the unique point with minimum distance to `p` or None
/// if no unique point exists.
returns the index of the unique point with minimum distance to `p` or None
if no unique point exists.
returns the index of the unique point with minimum distance to ` p ` or None if no unique point exists .
fn min_point(points: &[Vec2], p: Vec2) -> Option<usize> {
  let mut iter = points.iter().enumerate();
  let (id, &p2) = iter.next().unwrap();
  let mut min_dist = city_dist(p, p2);
  let mut min_id = id;
  let mut count = 1usize;
  for (id, &p2) in iter {
    let dist = city_dist(p, p2);
    match dist.cmp(&min_dist) {
      Ordering::Less => {
        min_dist = dist;
        min_id = id;
        count = 1;
      }
      Ordering::Equal => count += 1,
      Ordering::Greater => {}
    }
  }
  (count == 1).then(|| min_id)
}
fn min_point ( points : & [ Vec2 ] , p : Vec2 ) -> Option < usize > { let mut iter = points . iter ( ) . enumerate ( ) ; let ( id , & p2 ) = iter . next ( ) . unwrap ( ) ; let mut min_dist = city_dist ( p , p2 ) ; let mut min_id = id ; let mut count = 1usize ; for ( id , & p2 ) in iter { let dist = city_dist ( p , p2 ) ; match dist . cmp ( & min_dist ) { Ordering :: Less => { min_dist = dist ; min_id = id ; count = 1 ; } Ordering :: Equal => count += 1 , Ordering :: Greater => { } } } ( count == 1 ) . then ( | | min_id ) }
returns the index of the unique point with minimum distance to `p` or None
if no unique point exists.
returns the index of the unique point with minimum distance to ` p ` or None if no unique point exists .
points
&[Vec2]
p
Vec2
points
&[Vec2]
p
Vec2