Challenge 2: Calling C's sqrt via FFI — Possible Solution ==================================================================== extern "C" { fn sqrt(x: f64) -> f64; } fn main() { let result = unsafe { sqrt(16.0) }; println!("{}", result); // 4 } WHY THIS WORKS AS AN ANSWER ------------------------------ The extern "C" block declares sqrt's signature to Rust WITHOUT providing any Rust implementation for it — this tells the compiler "a function matching this exact signature exists somewhere, compiled from C, and will be linked in" — exactly this chapter's pattern for declaring a foreign function, following the abs example directly. Calling sqrt(16.0) is wrapped in an unsafe block because ALL calls to extern "C" functions require it, per this chapter's explanation: the Rust compiler has no way to verify a foreign, non-Rust function's internal safety guarantees — it simply trusts the declared signature and the caller's own judgment that using it is sound. Since sqrt is a standard C math library function widely available on the linking platform (part of libm), no special build configuration is needed for this to link successfully in most environments — a concrete, minimal example of exactly the "interop with existing C libraries" use case this chapter named as FFI's genuinely practical purpose.