struct UnusedConfig {
debug_mode: bool,
max_retries: u32,
timeout: u64,
}
enum Status {
Pending,
Running,
Complete,
Failed,
}
fn unused_helper(x: i32, y: i32) -> i32 {
x * y + 100
}
fn deprecated_format(s: &str) -> String {
format!("[DEPRECATED] {s}")
}
const MAX_BUFFER_SIZE: usize = 4096;
const DEFAULT_TIMEOUT: u64 = 30;
pub struct Calculator {
history: Vec<String>,
}
impl Default for Calculator {
fn default() -> Self {
Self::new()
}
}
impl Calculator {
pub fn new() -> Self {
Self {
history: Vec::new(),
}
}
pub fn add(&mut self, a: i32, b: i32) -> i32 {
let result = a + b;
self.history.push(format!("{a} + {b} = {result}"));
result
}
pub fn get_history(&self) -> &Vec<String> {
&self.history
}
}
fn main() {
let mut calc = Calculator::new();
let sum = calc.add(5, 3);
println!("Sum: {sum}");
for entry in calc.get_history() {
println!("{entry}");
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add() {
let mut calc = Calculator::new();
assert_eq!(calc.add(2, 3), 5);
}
}