| Crates.io | elements_rs |
| lib.rs | elements_rs |
| version | 0.1.2 |
| created_at | 2025-11-05 12:32:16.95514+00 |
| updated_at | 2026-01-25 07:13:11.519409+00 |
| description | A comprehensive library for chemical elements and their isotopes with rich metadata |
| homepage | |
| repository | https://github.com/earth-metabolome-initiative/elements-rs |
| max_upload_size | |
| id | 1917927 |
| size | 1,779,848 |
A comprehensive Rust crate providing type-safe enumerations and rich metadata for all chemical elements of the periodic table and their isotopes. The crate includes all 118 elements from Hydrogen to Oganesson with detailed information for each isotope including mass numbers, relative atomic masses, isotopic composition, and identification of the most abundant isotope. Chemical properties are fully supported: standard atomic weights, oxidation states with validation, valence electrons, bond numbers, electron configurations with atomic orbitals, and principal quantum numbers.
The crate is no_std, and optionally supports serde for serialization/deserialization.
Add this to your Cargo.toml:
[dependencies]
elements_rs = "0.1"
use elements_rs::{Element, BondsNumber, ValenceElectrons};
// Get an element
let carbon = Element::C;
// Access properties
println!("Name: {}", carbon.name());
println!("Atomic weight: {}", carbon.standard_atomic_weight());
println!("Valence electrons: {}", carbon.valence_electrons());
// Check oxidation states
assert!(carbon.is_valid_oxidation_state(4));
assert!(carbon.is_valid_oxidation_state(-4));
// Get bond information
let (min_bonds, max_bonds) = carbon.number_of_bonds();
assert_eq!((min_bonds, max_bonds), (4, 4));
use elements_rs::isotopes::{CarbonIsotope, Isotope, MassNumber, RelativeAtomicMass};
// Get a specific isotope
let carbon_12 = CarbonIsotope::C12;
println!("Mass number: {}", carbon_12.mass_number());
println!("Relative atomic mass: {}", carbon_12.relative_atomic_mass());
// Work with the generic Isotope enum
let isotope = Isotope::C(carbon_12);
use elements_rs::Element;
use std::str::FromStr;
// Parse element symbols
let oxygen = Element::from_str("O").unwrap();
let nitrogen = Element::from_str("N").unwrap();
serde (default): Enables Serialize and Deserialize implementations for Element and Isotope typesThis project is licensed under the same terms as the parent EMI monorepo.