{ "body": "You call Rust from C by compiling Rust code into a static library and linking it with your C program using extern "C" to prevent name mangling.\n\nrust\n// lib.rs\n#[no_mangle]\npub extern \"C\" fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n\n\nbash\n# Build the Rust library\ncargo build --release --lib\n# Compile and link with C\ngcc main.c -L target/release -lmy_rust_lib -o my_app\n\n\nc\n// main.c\n#include <stdio.h>\nextern int add(int a, int b);\n\nint main() {\n printf(\"Result: %d\\n\", add(2, 3));\n return 0;\n}\n", "simple": "This process lets your C program use functions written in Rust by treating the Rust code as a pre-built tool. Think of it like plugging a specialized appliance into a standard wall outlet; you just need the right adapter to make them work together. You use this when you need Rust's speed or safety for specific tasks while keeping the rest of your system in C.", "summary": "Call Rust from C by compiling Rust as a static library with extern \"C\" and linking it via gcc." }