fn module_init(py: Python, m: &PyModule) -> PyResult<()> {
    let mut state = get_module_state(py, m)?;

    unsafe {
        state.register_filesystem_importer = (*NEXT_MODULE_STATE).register_filesystem_importer;
        // TODO we could move the value if we wanted to avoid the clone().
        state.sys_paths = (*NEXT_MODULE_STATE).sys_paths.clone();
        state.py_modules_data = (*NEXT_MODULE_STATE).py_modules_data;
        state.py_resources_data = (*NEXT_MODULE_STATE).py_resources_data;
    }

    state.setup_called = false;

    m.add(
        py,
        "_setup",
        py_fn!(
            py,
            module_setup(
                m: PyModule,
                bootstrap_module: PyModule,
                marshal_module: PyModule,
                decode_source: PyObject
            )
        ),
    )?;

    Ok(())
}
/// Initialize the Python module object.
///
/// This is called as part of the PyInit_* function to create the internal
/// module object for the interpreter.
///
/// This receives a handle to the current Python interpreter and just-created
/// Python module instance. It populates the internal module state and registers
/// a _setup() on the module object for usage by Python.
///
/// Because this function accesses NEXT_MODULE_STATE, it should only be
/// called during interpreter initialization.
Initialize the Python module object.
This is called as part of the PyInit_* function to create the internal
module object for the interpreter.

This receives a handle to the current Python interpreter and just-created
Python module instance. It populates the internal module state and registers
a _setup() on the module object for usage by Python.

Because this function accesses NEXT_MODULE_STATE, it should only be
called during interpreter initialization.
Initialize the Python module object . This is called as part of the PyInit_ * function to create the internal module object for the interpreter . This receives a handle to the current Python interpreter and just - created Python module instance . It populates the internal module state and registers a _setup () on the module object for usage by Python . Because this function accesses NEXT_MODULE_STATE it should only be called during interpreter initialization .
fn module_init(py: Python, m: &PyModule) -> PyResult<()> {
    let mut state = get_module_state(py, m)?;
    unsafe {
        state.register_filesystem_importer = (*NEXT_MODULE_STATE).register_filesystem_importer;
        // TODO we could move the value if we wanted to avoid the clone().
        state.sys_paths = (*NEXT_MODULE_STATE).sys_paths.clone();
        state.py_modules_data = (*NEXT_MODULE_STATE).py_modules_data;
        state.py_resources_data = (*NEXT_MODULE_STATE).py_resources_data;
    }
    state.setup_called = false;
    m.add(
        py,
        "_setup",
        py_fn!(
            py,
            module_setup(
                m: PyModule,
                bootstrap_module: PyModule,
                marshal_module: PyModule,
                decode_source: PyObject
            )
        ),
    )?;
    Ok(())
}
fn module_init ( py : Python , m : & PyModule ) -> PyResult < ( ) > { let mut state = get_module_state ( py , m ) ? ; unsafe { state . register_filesystem_importer = ( * NEXT_MODULE_STATE ) . register_filesystem_importer ; // TODO we could move the value if we wanted to avoid the clone(). state . sys_paths = ( * NEXT_MODULE_STATE ) . sys_paths . clone ( ) ; state . py_modules_data = ( * NEXT_MODULE_STATE ) . py_modules_data ; state . py_resources_data = ( * NEXT_MODULE_STATE ) . py_resources_data ; } state . setup_called = false ; m . add ( py , " " , py_fn ! ( py module_setup ( m PyModule bootstrap_module PyModule marshal_module PyModule decode_source PyObject ) ) , ) ? ; Ok ( ( ) ) }
Initialize the Python module object.
Initialize the Python module object .
py
Python
m
&PyModule