1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Pint-inspired unit system: dimensions, units, registry, parser, quantities.
//!
//! A [`UnitRegistry`] holds [`UnitDef`] entries over the 7 SI base dimensions,
//! an internal recursive-descent parser turns compound expressions
//! (`"kcal/mol/angstrom"`) into self-contained [`Unit`] values, and
//! [`Quantity`] provides dimension-checked arithmetic and conversion.
//!
//! Every unit is reduced at parse time to `(factor, offset, Dimension)` with
//! conversion to SI base defined as `si = value * factor + offset`; the
//! `offset` is non-zero only for affine units such as `degC`. Conversion
//! factors are SI-2019 exact or CODATA 2018 recommended values (see
//! [`constants`] and the registry preload tables in `registry.rs`).
//!
//! Reference: design follows pint (Python),
//! <https://pint.readthedocs.io/en/stable/>.
//!
//! # Examples
//!
//! Energy conversion and dimension checking:
//!
//! ```
//! use molrs::units::{UnitRegistry, UnitsError};
//!
//! let reg = UnitRegistry::new();
//!
//! // 1 kcal/mol = 4.184 kJ/mol (thermochemical calorie, exact).
//! let e = reg.quantity(1.0, "kcal/mol")?;
//! let kj = e.to(®.parse("kJ/mol")?)?;
//! assert!((kj.value() - 4.184).abs() < 1e-12);
//!
//! // Converting an energy to a length is a dimension error.
//! let err = e.to(®.parse("angstrom")?).unwrap_err();
//! assert!(matches!(err, UnitsError::DimensionMismatch { .. }));
//! # Ok::<(), UnitsError>(())
//! ```
pub use Dimension;
pub use UnitsError;
pub use Quantity;
pub use ;
pub use Unit;