|
| 1 | +# Calculator Library (Rust) |
| 2 | + |
| 3 | +A simple calculator library demonstrating Rust documentation with sphinx-rust. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Basic arithmetic operations (add, subtract, multiply, divide) |
| 8 | +- Scientific calculator with trigonometric and logarithmic functions |
| 9 | +- Operation history tracking |
| 10 | +- Full Rust documentation with examples |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | +```rust |
| 15 | +use calculator::{Calculator, Operation}; |
| 16 | + |
| 17 | +fn main() { |
| 18 | + let mut calc = Calculator::new(); |
| 19 | + |
| 20 | + // Basic operations |
| 21 | + let sum = calc.add(5.0, 3.0); |
| 22 | + println!("5 + 3 = {}", sum); |
| 23 | + |
| 24 | + let product = calc.multiply(4.0, 7.0); |
| 25 | + println!("4 * 7 = {}", product); |
| 26 | + |
| 27 | + // View history |
| 28 | + for result in calc.history() { |
| 29 | + println!("{}", result); |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +## Scientific Calculator |
| 35 | + |
| 36 | +```rust |
| 37 | +use calculator::ScientificCalculator; |
| 38 | + |
| 39 | +fn main() { |
| 40 | + let mut sci = ScientificCalculator::new(); |
| 41 | + sci.set_use_degrees(true); |
| 42 | + |
| 43 | + println!("sin(90°) = {}", sci.sin(90.0)); |
| 44 | + println!("sqrt(16) = {}", sci.sqrt(16.0)); |
| 45 | + println!("2^10 = {}", sci.pow(2.0, 10.0)); |
| 46 | +} |
| 47 | +``` |
0 commit comments