4 releases
Uses new Rust 2024
new 0.1.3 | Apr 11, 2025 |
---|---|
0.1.2 | Apr 11, 2025 |
0.1.1 | Apr 11, 2025 |
0.1.0 | Apr 11, 2025 |
#7 in #health
19KB
473 lines
diet-calc
diet-calc is a Rust library that allows users to calculate key nutritional and health metrics:
- Body Mass Index (BMI)
- Basal Metabolic Rate (BMR)
- Total Daily Energy Expenditure (TDEE)
- Waist-to-Height Ratio (WHtR)
- Body Adiposity Index (BAI)
These metrics assist dietitians and health-conscious individuals in assessing body composition and daily caloric requirements.
Features
- BMI Calculation: Evaluates body weight status.
- BMR Calculation: Calculates resting caloric needs.
- TDEE Calculation: Estimates daily caloric expenditure based on activity level.
- WHtR Calculation: Assesses abdominal obesity risk.
- BAI Calculation: Estimates body fat percentage without direct body composition measurement.
Formulas Used
BMI (Body Mass Index)
BMI categories according to the World Health Organization (WHO):
- Underweight: <18.5
- Normal weight: 18.5–24.9
- Overweight: 25–29.9
- Obesity: ≥30
BMR (Basal Metabolic Rate)
BMR calculated using the Mifflin-St Jeor equation (Mifflin et al., 1990):
TDEE (Total Daily Energy Expenditure)
TDEE is BMR multiplied by an activity factor (source)
- Sedentary: BMR × 1.2
- Lightly active: BMR × 1.375
- Moderately active: BMR × 1.55
- Very active: BMR × 1.725
- Super active: BMR × 1.9
WHtR (Waist-to-Height Ratio)
WHtR values >0.5 indicate increased cardiovascular and metabolic risk (Browning et al., 2010).
BAI (Body Adiposity Index)
BAI estimates body fat percentage:
Formula from Bergman et al., 2011.
System Requirements
- Rust programming language (1.65+)
Installation
Clone, build, and run the project:
git clone https://github.com/mycotoxin/diet-calc.git
cd diet-calc
cargo build --release
use diet_calc::formulas::bmi;
use uom::si::f32::{ Length, Mass};
use uom::si::length::centimeter;
use uom::si::mass::kilogram;
fn main() {
let bmi: f32 = bmi(Mass::new::<kilogram>(70.0), Length::new::<centimeter>(184.0)).unwrap();
println!("BMR Result is: {} ", bmi);
}
License
This project is licensed under the MIT License. See the LICENSE file for details.
Dependencies
~1.5MB
~30K SLoC