Skip to main content

build_class_name_index

Function build_class_name_index 

Source
fn build_class_name_index<'a>(
    entries: impl IntoIterator<Item = &'a ClassNameEntry>,
) -> HashMap<&'a str, &'a ClassNameEntry>
Expand description

Build the rust_type → ClassNameEntry lookup used by every placeholder resolver in write_r_wrappers_to_file.

Each #[miniextendr] impl block of a type registers a ClassNameEntry (#1242, #1776) — the class name is a property of the type, so identical duplicates collapse here. Conflicting registrations (same rust_type, different r_class_name or class_system — e.g. two blocks with disagreeing class = "..." overrides) panic: silently keeping whichever entry linkme ordered last would resolve .__MX_CLASS_REF_*__ placeholders nondeterministically. field_syntax may differ between the blocks (sidecar_accessor_fragments reads every entry). Distinct Rust types must also have distinct R class names: otherwise their class bindings and generated methods overwrite each other when the package loads (#1677).

Host-only like MX_CLASS_NAMES itself — the consumers all live in the wrapper-writing path, which never runs on wasm32.