The Rust attribute #[no_mangle] prevents the compiler from mangling an item’s symbol name. It is useful when C code must find a Rust function by name: otherwise, the linker may look for solve while Rust has given the function a name such as _ZN9calculate5solve17h6ed798464632de3fE. section 3.2.2
Listing 3.6 Rust solve function that can be exported as compatible with C
#[no_mangle]
pub extern "C" fn solve(
line: *const c_char, solution: *mut c_int) -> c_int {
0
}
This function combines #[no_mangle] with pub and extern "C" so C can call solve by name. The attribute controls the symbol name; pub exposes the function, and extern "C" selects C calling conventions. section 3.2.2
Disabling mangling means the name must not clash with another symbol. A C-style prefix, such as ngx_http_calculator_, helps distinguish an exported function from others. section 3.2.2 section 4.4
#[no_mangle] pub unsafe extern "C" fn ngx_http_calculator_handler unsafe extern "C" fn read_body_handler unsafe fn request_body_as_str
Not every function callable from C needs #[no_mangle]. The handler is called by name, but the callback is passed by address, so it needs extern "C" without a public, unmangled name. The Rust-only helper needs neither annotation. section 4.4

