What is the cfg attribute

The #[cfg(test)] attribute includes code only during test execution, excluding it from production builds.

The #[cfg(test)] attribute tells the Rust compiler to include the following code block only when running tests.

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

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }
}

This keeps test code out of your production binary, reducing size and preventing accidental execution of test logic in your final application.