use std::os::raw; /// Return The Answer. /// /// # Example /// /// ``` /// let a = call_rust_from_c::answer(); /// assert_eq!(a, 42); /// ``` #[no_mangle] // C 'int'; it does not actually hurt to have more specific types such as int32_t, but it's good to know that plain ints work pub extern "C" fn answer() -> raw::c_int { return 42; } #[cfg(test)] mod tests { use super::*; #[test] fn test_answer() { assert_eq!(answer(), 42); } }