xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/bindgen/main.rs (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan //! rust_bindgen_library example consumer
2*d4726bddSHONG Yifan 
simple_function() -> i643*d4726bddSHONG Yifan fn simple_function() -> i64 {
4*d4726bddSHONG Yifan     unsafe { simple_bindgen::simple_function() }
5*d4726bddSHONG Yifan }
6*d4726bddSHONG Yifan 
simple_static_function() -> i647*d4726bddSHONG Yifan fn simple_static_function() -> i64 {
8*d4726bddSHONG Yifan     unsafe { simple_bindgen::simple_static_function() }
9*d4726bddSHONG Yifan }
10*d4726bddSHONG Yifan 
main()11*d4726bddSHONG Yifan fn main() {
12*d4726bddSHONG Yifan     println!(
13*d4726bddSHONG Yifan         "The values are {}, {}, and {}!",
14*d4726bddSHONG Yifan         simple_bindgen::SIMPLE_VALUE,
15*d4726bddSHONG Yifan         simple_function(),
16*d4726bddSHONG Yifan         simple_static_function(),
17*d4726bddSHONG Yifan     );
18*d4726bddSHONG Yifan }
19*d4726bddSHONG Yifan 
20*d4726bddSHONG Yifan #[cfg(test)]
21*d4726bddSHONG Yifan mod test {
22*d4726bddSHONG Yifan     #[test]
do_the_test()23*d4726bddSHONG Yifan     fn do_the_test() {
24*d4726bddSHONG Yifan         assert_eq!(42, simple_bindgen::SIMPLE_VALUE);
25*d4726bddSHONG Yifan         assert_eq!(1337, super::simple_function());
26*d4726bddSHONG Yifan         assert_eq!(84, super::simple_static_function());
27*d4726bddSHONG Yifan     }
28*d4726bddSHONG Yifan }
29