You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lib.rs
    path of file: ./repos/Theseus/kernel/pci/src
    
    the code of the file until where you have to start completion: //! PCI Configuration Space Access
//!
//! ## Terminology
//!
//! This crate deals with multiple types of interrupts:
//! * Legacy (INTx) interrupts are the oldest PCI interrupt representation.
//!   * Four interrupt pins are shared among all devices.
//!   * This crate refers to these legacy interrupts as "intx".
//!
//! * MSI (Message Signaled Interrupts) appeared with PCI express.
//!   * They allow devices to allocate up to 32 interrupt numbers.
//!   * This crate refers to these interrupts as "msi".
//!
//! * MSI-X messages appeared with
    
fn init_intx_handler(int_num: InterruptNumber) -> Result<(), &'static str> {
    let mut intx_numbers = INTX_NUMBERS.lock();
    let mut slot = None;

    for i in 0..4 {
        if intx_numbers[i] == Some(int_num) {
            return Ok((/* this interrupt number was already initialized. */));
        } else if intx_numbers[i].is_none() {
            slot = Some(i);
        }
    }

    let slot = slot.ok_or("More than four different INTx numbers were encountered")?;
    intx_numbers[slot] = Some(int_num);
    core::mem::drop(intx_numbers);

    let pci_intx_handler = HANDLERS[slot];
    if let Err(existing_handler) = register_interrupt(int_num, pci_intx_handler) {
        if existing_handler != (pci_intx_handler as _) {
            return Err("Couldn't lazily set PCI INTx handler");
        }
    }

    #[cfg(target_arch = "aarch64")] {
        let int_dst = Some(cpu::bootstrap_cpu().unwrap());
        let int_ctrl = SystemInterruptController::get()
            .ok_or("SystemInterruptController was not yet initialized")?;

        // route interrupt to bootstrap processor
        int_ctrl.set_destination(int_num, int_dst, u8::MAX)?;
    }

    Ok(())
}