xref: /aosp_15_r20/external/bazelbuild-rules_rust/test/unit/rustdoc/rustdoc_lib.rs (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1 #[cfg(feature = "with_proc_macro")]
2 use rustdoc_proc_macro::make_answer;
3 
4 #[cfg(feature = "with_proc_macro")]
5 make_answer!();
6 
7 #[cfg(feature = "with_build_script")]
8 pub const CONST: &str = env!("CONST");
9 
10 /// The answer to the ultimate question
11 /// ```
12 /// fn answer() -> u32 { 42 }
13 /// assert_eq!(answer(), 42);
14 /// ```
15 ///
16 /// ```
17 /// use adder::inc;
18 /// assert_eq!(inc(41), 42);
19 /// ```
20 #[cfg(not(feature = "with_proc_macro"))]
answer() -> u3221 pub fn answer() -> u32 {
22     42
23 }
24 
25 #[cfg(test)]
26 mod test {
27     use super::*;
28 
29     #[test]
test_answer()30     fn test_answer() {
31         assert_eq!(answer(), 42);
32     }
33 }
34