1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pub mod sub;
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

fn private_add(a: i32, b: i32) -> i32 {
    a + b
}

pub fn public_add(a: i32, b: i32) -> i32 {
    a + b
}

pub fn other_fn() {
    println!("other_fn");
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
    #[test]
    fn add_test() {
        assert_eq!(2, super::add(1, 1));
    }
    #[test]
    fn add_sub() {
        assert_eq!(0, crate::sub::sub(1, 1));
    }
}