pub struct AtomicMassLookup { /* private fields */ }Expand description
A caller-controlled element atomic-mass lookup table.
Implementations§
Source§impl AtomicMassLookup
impl AtomicMassLookup
Sourcepub fn from_entries(entries: impl IntoIterator<Item = AtomicMassEntry>) -> Self
pub fn from_entries(entries: impl IntoIterator<Item = AtomicMassEntry>) -> Self
Creates a lookup table from validated entries.
Sourcepub fn from_pairs<'a>(
entries: impl IntoIterator<Item = (&'a str, f64)>,
) -> Result<Self, MolarMassValidationError>
pub fn from_pairs<'a>( entries: impl IntoIterator<Item = (&'a str, f64)>, ) -> Result<Self, MolarMassValidationError>
Creates a lookup table from symbol and mass pairs.
§Errors
Returns a molar-mass validation error when any entry is invalid.
Sourcepub fn from_formula(
formula: &ChemicalFormula,
) -> Result<Self, MolarMassValidationError>
pub fn from_formula( formula: &ChemicalFormula, ) -> Result<Self, MolarMassValidationError>
Creates a lookup table for the symbols present in a formula using RustUse atomic masses.
§Errors
Returns MolarMassValidationError::MissingAtomicMass if a formula symbol
is not present in the RustUse atomic-mass table. Returns another
molar-mass validation error if a generated entry is invalid.
Sourcepub fn insert(&mut self, entry: AtomicMassEntry) -> Option<f64>
pub fn insert(&mut self, entry: AtomicMassEntry) -> Option<f64>
Inserts a validated atomic mass entry and returns the previous value, if any.
Sourcepub fn insert_atomic_mass(
&mut self,
symbol: &str,
atomic_mass: f64,
) -> Result<Option<f64>, MolarMassValidationError>
pub fn insert_atomic_mass( &mut self, symbol: &str, atomic_mass: f64, ) -> Result<Option<f64>, MolarMassValidationError>
Validates and inserts an atomic mass entry.
§Errors
Returns a molar-mass validation error when the symbol or atomic mass is invalid.
Sourcepub fn atomic_mass(&self, symbol: &str) -> Option<f64>
pub fn atomic_mass(&self, symbol: &str) -> Option<f64>
Returns the atomic mass for a symbol.
Sourcepub fn entry(&self, symbol: &str) -> Option<AtomicMassEntry>
pub fn entry(&self, symbol: &str) -> Option<AtomicMassEntry>
Returns a copy of the stored entry for a symbol.
Sourcepub fn contains_symbol(&self, symbol: &str) -> bool
pub fn contains_symbol(&self, symbol: &str) -> bool
Returns true when the lookup contains a symbol.
Trait Implementations§
Source§impl Clone for AtomicMassLookup
impl Clone for AtomicMassLookup
Source§fn clone(&self) -> AtomicMassLookup
fn clone(&self) -> AtomicMassLookup
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more