pub fn sanity_check(&self, other: &Self, t: fn(Coord) -> Coord, o: &Coord) {
        // create a copy of other in self's coordinates
        let mut other = other.to_owned();
        other.transform(t, o);

        // loop over beacons seen by self
        for b1 in &self.beacons {
            let d = other.pos.sub(b1);
            let in_range = RANGE.contains(&d.0) && RANGE.contains(&d.1) && RANGE.contains(&d.2);
            let contained = other.beacons.contains(b1);
            if in_range != contained {
                panic!(
                    "{} is in range of 2nd scanner {} at {}, but not contained in set or vice versa",
                    b1, other.id, other.pos
                );
            }
        }

        // loop over beacons seen by other
        for b2 in &other.beacons {
            let d = self.pos.sub(b2);
            let in_range = RANGE.contains(&d.0) && RANGE.contains(&d.1) && RANGE.contains(&d.2);
            let contained = self.beacons.contains(b2);
            if in_range != contained {
                panic!(
                    "{} is in range of 1st scanner {} at {}, but not contained in set or vice versa",
                    b2, self.id, self.pos
                );
            }
        }
    }
// tag::sanity[]
/// sanity check for overlapping scanner regions
///
/// for all beacons seen by self / other, check whether they are also seen by other / self
/// if and only if they are in range of other / self
///
/// # Panics
/// if sanity check fails
:sanity[]
sanity check for overlapping scanner regions

for all beacons seen by self / other, check whether they are also seen by other / self
if and only if they are in range of other / self
: sanity [] sanity check for overlapping scanner regions for all beacons seen by self / other check whether they are also seen by other / self if and only if they are in range of other / self
pub fn sanity_check(&self, other: &Self, t: fn(Coord) -> Coord, o: &Coord) {
        // create a copy of other in self's coordinates
        let mut other = other.to_owned();
        other.transform(t, o);
        // loop over beacons seen by self
        for b1 in &self.beacons {
            let d = other.pos.sub(b1);
            let in_range = RANGE.contains(&d.0) && RANGE.contains(&d.1) && RANGE.contains(&d.2);
            let contained = other.beacons.contains(b1);
            if in_range != contained {
                panic!(
                    "{} is in range of 2nd scanner {} at {}, but not contained in set or vice versa",
                    b1, other.id, other.pos
                );
            }
        }
        // loop over beacons seen by other
        for b2 in &other.beacons {
            let d = self.pos.sub(b2);
            let in_range = RANGE.contains(&d.0) && RANGE.contains(&d.1) && RANGE.contains(&d.2);
            let contained = self.beacons.contains(b2);
            if in_range != contained {
                panic!(
                    "{} is in range of 1st scanner {} at {}, but not contained in set or vice versa",
                    b2, self.id, self.pos
                );
            }
        }
    }
pub fn sanity_check ( & self , other : & Self , t : fn ( Coord ) -> Coord , o : & Coord ) { // create a copy of other in self's coordinates let mut other = other . to_owned ( ) ; other . transform ( t , o ) ; // loop over beacons seen by self for b1 in & self . beacons { let d = other . pos . sub ( b1 ) ; let in_range = RANGE . contains ( & d . 0 ) && RANGE . contains ( & d . 1 ) && RANGE . contains ( & d . 2 ) ; let contained = other . beacons . contains ( b1 ) ; if in_range != contained { panic ! ( " " b1 other id other pos ) ; } } // loop over beacons seen by other for b2 in & other . beacons { let d = self . pos . sub ( b2 ) ; let in_range = RANGE . contains ( & d . 0 ) && RANGE . contains ( & d . 1 ) && RANGE . contains ( & d . 2 ) ; let contained = self . beacons . contains ( b2 ) ; if in_range != contained { panic ! ( " " b2 self id self pos ) ; } } }
tag::sanity[]
sanity check for overlapping scanner regions
tag :: sanity [] sanity check for overlapping scanner regions
&self
other
&Self
t
fn(Coord) -> Coord
o
&Coord
&self
other
&Self
t
fn(Coord) -> Coord
o
&Coord
panics
if sanity check fails
if sanity check fails