/// Assert invariants about slot initialization.
///
/// * Check that the slots referenced by scans are all in bounds.
/// * Check that scans only read from slots that were written to by earlier scans.
/// * Check that every slot is written to by at least one scan or constant.
/// * Check that every slot is written to by at most one scan or constant.
///
/// Panics if any of the invariants is violated.
Assert invariants about slot initialization.
Check that the slots referenced by scans are all in bounds.
Check that scans only read from slots that were written to by earlier scans.
Check that every slot is written to by at least one scan or constant.
Check that every slot is written to by at most one scan or constant.

Panics if any of the invariants is violated.
Assert invariants about slot initialization . Check that the slots referenced by scans are all in bounds . Check that scans only read from slots that were written to by earlier scans . Check that every slot is written to by at least one scan or constant . Check that every slot is written to by at most one scan or constant . Panics if any of the invariants is violated .
fn check_slot_initialization(&self) {
        // For every slot, we store how it is initialized.
        #[derive(Eq, Debug, PartialEq)]
        enum Initialization {
            /// Not initialized yet, safe to write, unsafe to read.
            Uninitialized,
            /// Initialized to a constant value.
            Constant,
            /// Initialized by the scan with the given scan number.
            Scan(usize),
        };
        let mut initialization = Vec::with_capacity(self.slots.len());
        for slot_def in &self.slots {
            match *slot_def {
                SlotDefinition::Variable { .. } => initialization.push(Initialization::Uninitialized),
                SlotDefinition::Constant { .. } => initialization.push(Initialization::Constant),
            }
        }
        for (i_scan, scan) in self.scans.iter().enumerate() {
            let is_writes = match scan.flow {
                Flow::OutOut => [true, true],
                Flow::InOut => [false, true],
                Flow::InIn => [false, false],
            };
            for (slot, &is_write) in scan.slots().as_ref().iter().zip(is_writes.as_ref()) {
                assert!(
                    (slot.0 as usize) < self.scans.len(),
                    "Scan {} references non-existing slot {}.",
                    i_scan, slot.0,
                );
                let init = &mut initialization[slot.0 as usize];
                if is_write {
                    assert_eq!(
                        *init, Initialization::Uninitialized,
                        "Scan {} writes to slot {}, which is already initialized by {:?}.",
                        i_scan, slot.0, *init,
                    );
                    *init = Initialization::Scan(i_scan);
                } else {
                    assert!(
                        *init != Initialization::Uninitialized,
                        "Scan {} reads uninitialized slot {}.",
                        i_scan, slot.0
                    );
                }
            }
        }
        for (i_slot, init) in initialization.iter().enumerate() {
            assert!(
                *init != Initialization::Uninitialized,
                "The plan does not initialize slot {}.",
                i_slot,
            );
        }
    }
fn check_slot_initialization ( & self ) { // For every slot, we store how it is initialized. # [ derive ( Eq Debug PartialEq ) ] enum Initialization { /// Not initialized yet, safe to write, unsafe to read. Uninitialized , /// Initialized to a constant value. Constant , /// Initialized by the scan with the given scan number. Scan ( usize ) , } ; let mut initialization = Vec :: with_capacity ( self . slots . len ( ) ) ; for slot_def in & self . slots { match * slot_def { SlotDefinition :: Variable { .. } => initialization . push ( Initialization :: Uninitialized ) , SlotDefinition :: Constant { .. } => initialization . push ( Initialization :: Constant ) , } } for ( i_scan , scan ) in self . scans . iter ( ) . enumerate ( ) { let is_writes = match scan . flow { Flow :: OutOut => [ true , true ] , Flow :: InOut => [ false , true ] , Flow :: InIn => [ false , false ] , } ; for ( slot , & is_write ) in scan . slots ( ) . as_ref ( ) . iter ( ) . zip ( is_writes . as_ref ( ) ) { assert ! ( ( slot 0 as usize ) self scans len ( ) " " i_scan slot 0 ) ; let init = & mut initialization [ slot . 0 as usize ] ; if is_write { assert_eq ! ( init Initialization Uninitialized " " i_scan slot 0 init ) ; * init = Initialization :: Scan ( i_scan ) ; } else { assert ! ( init Initialization Uninitialized " " i_scan slot 0 ) ; } } } for ( i_slot , init ) in initialization . iter ( ) . enumerate ( ) { assert ! ( init Initialization Uninitialized " " i_slot ) ; } }
Assert invariants about slot initialization.
Assert invariants about slot initialization .
&self