Expand description
§RUnits - GNU Units-inspired unit converter in Rust
RUnits is a powerful, type-safe unit conversion tool with support for compound units, dimensional analysis, and interactive mode.
§Quick Start
use runits::{Unit, Quantity};
use runits::units::dimension::Dimension;
// Create a quantity
let distance = Quantity::new(10.0, Unit::foot());
// Convert to another unit
let meters = distance.convert_to(&Unit::meter()).unwrap();
println!("{}", meters); // Prints: 3.048 meter§Features
- Type-safe conversions: Dimensional analysis prevents invalid conversions
- Compound units: Support for complex units like
kg*m/s^2 - Extensive unit database: SI, Imperial, and specialized units
- CLI interface: Direct command-line unit conversions
- Interactive mode: REPL for exploratory unit calculations
§CLI Usage
# Basic conversion
runits "10 ft" "m"
# Compound units
runits "100 km/hr" "m/s"
# Interactive mode
runitsRe-exports§
pub use error::RUnitsError;pub use units::Dimension;pub use units::Quantity;pub use units::Unit;
Modules§
- annotations
- Dimension-signature → physical-quantity name registry.
- cli
- clap-derived CLI argument layout.
- config
- Optional TOML configuration file at
~/.config/runits/config.toml. - convert
- Core conversion logic, decoupled from CLI and presentation.
- database
- In-memory registry of known units + aliases.
- error
- Unified error type for the runits crate.
- eval
- Tree walker / evaluator for
Exprtrees. - expr
- Expression AST for source-side input parsing.
- format
- Output formatting: composes precision, color, Unicode, annotations, and JSON into a single presentation layer.
- math
- Math function registry — foundation for a Numbat-style math prelude.
- parser
- Pest-backed parser with full source-side expression support.
- repl
- Interactive REPL mode.
- theme
- Dimension-based color theme for consistent styling.
- units