Expand description
§Elements
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.
Would you like to see more information or features? Please open an issue or a pull request!
The crate is no_std, and optionally supports serde for serialization/deserialization and arbitrary for fuzzing.
§Usage
Add this to your Cargo.toml:
[dependencies]
elements_rs = "0.1"§Basic Example
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));§Working with Isotopes
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);§Parsing from Strings
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();§Feature Flags
serde(default): EnablesSerializeandDeserializeimplementations forElementandIsotopetypesarbitrary: EnablesArbitraryimplementations forElementandIsotopetypes, useful for fuzzing
§License
This project is licensed under the same terms as the parent EMI monorepo.
Re-exports§
pub use isotopes::ElementVariant;pub use isotopes::Isotope;pub use isotopes::IsotopicComposition;pub use isotopes::MassNumber;pub use isotopes::MostAbundantIsotope;pub use isotopes::RelativeAtomicMass;
Modules§
- errors
- Error types for element and isotope parsing.
- isotopes
- Isotopes for all chemical elements with mass numbers and atomic masses.
Structs§
- Atomic
Orbital - An atomic orbital with its quantum number and electron count.
- Element
Iter - An iterator over the variants of Element
- Element
Mask - Struct representing a set of elements as a bitmask.
Enums§
- Atomic
Orbital Type - Atomic orbital type (s, p, d, or f).
- Element
- All 118 elements of the periodic table.
Traits§
- Bonds
Number - Minimum and maximum number of bonds an element can form.
- Principal
Quantum Number - Number of electron shells in the atom.
- Valence
Electrons - Number of electrons in the outermost shell that participate in bonding.