| Crates.io | utomid-rs |
| lib.rs | utomid-rs |
| version | 0.1.0 |
| created_at | 2025-09-17 14:02:43.84729+00 |
| updated_at | 2025-09-17 14:02:43.84729+00 |
| description | Compact encoding for chemical elements, compounds, and basic chemistry utilities. |
| homepage | |
| repository | https://github.com/JDPlumbing/utomid-rs |
| max_upload_size | |
| id | 1843370 |
| size | 40,401 |
utomid-rs is a compact Rust library for representing chemical elements and compounds. Itβs designed for simulation and material modeling, with a focus on compact encoding and fast operations rather than full-blown chemistry accuracy.
Element struct)u8 representation[1, 1, 8] for HβO) or compact pairs ([(1,2), (8,1)])"H2O", "C6H12O6")Add this crate to your project:
cargo add utomid-rs
Or manually in Cargo.toml:
[dependencies]
utomid-rs = "0.1"
use utomid_rs::{CompactCompound, compound_formula, compound_mass};
// Expanded representation (array of atomic numbers)
let water = vec![1,1,8]; // H2O
println!("Formula: {}", compound_formula(&water));
println!("Mass: {}", compound_mass(&water));
// Compact representation
let water_compact = CompactCompound::new(vec![(1,2), (8,1)]);
println!("Formula: {}", water_compact.formula());
println!("Mass: {}", water_compact.mass());
Output:
Formula: H2O
Mass: 18.015
Run with:
cargo bench
Sample results (on a mid-tier CPU):
mass H2O (compact) time: ~18 ns
formula H2O (compact) time: ~92 ns
mass glucose (compact) time: ~27 ns
formula glucose (compact) ~165 ns
air, water, steel, etc.)Licensed under MIT.
See LICENSE for details.