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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

/// Calculates the area of a rectangle given its length and width.
///
/// # Arguments
///
/// * `length` - The length of the rectangle.
/// * `width` - The width of the rectangle.
///
/// # Returns
///
/// The area of the rectangle.
pub fn area(length: usize, width: usize) -> usize {
    length * width
}

/// Calculates the volume of a rectangular prism given its length, width, and height.
///
/// # Arguments
///
/// * `length` - The length of the rectangular prism.
/// * `width` - The width of the rectangular prism.
/// * `height` - The height of the rectangular prism.
///
/// # Returns
///
/// The volume of the rectangular prism.
pub fn volume(length: usize, width: usize, height: usize) -> usize {
    length * width * height
}

/// Calculates the perimeter of a rectangle given its length and width.
///
/// # Arguments
///
/// * `length` - The length of the rectangle.
/// * `width` - The width of the rectangle.
///
/// # Returns
///
/// The perimeter of the rectangle.
pub fn perimeter(length: usize, width: usize) -> usize {
    2 * (length + width)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = area(5, 2);
        assert_eq!(result, 10);
    }

    #[test]
    fn it_works2() {
        let result = volume(5, 2, 3);
        assert_eq!(result, 30);
    }

    #[test]
    fn it_works3() {
        let result = perimeter(5, 2);
        assert_eq!(result, 14);
    }
}