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
//! # Basic Area Crate
//! This is a collection of some generally used area function
//!
/// Find the Area
///
/// # Example
/// Area of Circle
/// ```
/// let radius = 12.0;
/// let answer = area_crate::area::circle(radius);
/// assert_eq!(452.38934211696005, answer);
/// ```
/// Area of Triangle
/// ```
/// let height = 20.0;
/// let width = 40.0;
/// let answer = area_crate::area::triangle(height, width);
/// assert_eq!(400.0, answer);
/// ```
/// Area of Square
/// ```
/// let length = 5;
/// let answer = area_crate::area::square(length);
/// assert_eq!(25, answer);
/// ```
/// Area of Rectangle
/// ```
/// let height = 20;
/// let width = 40;
/// let answer = area_crate::area::rectangle(height, width);
/// assert_eq!(800, answer);
/// ```
///
/// # Limitations
///
/// # Some other section
///
pub mod area {
pub fn circle(radius: f64) -> f64 {
let pi = 3.14159265359;
pi * radius * radius
}
pub fn triangle(height: f64, width: f64) -> f64 {
let area = 0.5 * height * width;
area
}
pub fn square(length: i32) -> i32 {
length * length
}
pub fn rectangle(height: i32, width: i32) -> i32 {
height * width
}
}