elements_rs 0.2.5

A comprehensive library for chemical elements and their isotopes with rich metadata
Documentation
//! Submodule implementing the `most_abundant_isotope` method for the `Element`
//! enumeration

use crate::isotopes::MostAbundantIsotope;

impl crate::Element {
    /// Returns the most common isotope of the element.
    #[must_use]
    #[allow(clippy::too_many_lines)]
    pub fn most_abundant_isotope(&self) -> super::Isotope {
        match self {
            Self::H => super::Isotope::H(super::HydrogenIsotope::most_abundant_isotope()),
            Self::He => super::Isotope::He(super::HeliumIsotope::most_abundant_isotope()),
            Self::Li => super::Isotope::Li(super::LithiumIsotope::most_abundant_isotope()),
            Self::Be => super::Isotope::Be(super::BerylliumIsotope::most_abundant_isotope()),
            Self::B => super::Isotope::B(super::BoronIsotope::most_abundant_isotope()),
            Self::C => super::Isotope::C(super::CarbonIsotope::most_abundant_isotope()),
            Self::N => super::Isotope::N(super::NitrogenIsotope::most_abundant_isotope()),
            Self::O => super::Isotope::O(super::OxygenIsotope::most_abundant_isotope()),
            Self::F => super::Isotope::F(super::FluorineIsotope::most_abundant_isotope()),
            Self::Ne => super::Isotope::Ne(super::NeonIsotope::most_abundant_isotope()),
            Self::Na => super::Isotope::Na(super::SodiumIsotope::most_abundant_isotope()),
            Self::Mg => super::Isotope::Mg(super::MagnesiumIsotope::most_abundant_isotope()),
            Self::Al => super::Isotope::Al(super::AluminiumIsotope::most_abundant_isotope()),
            Self::Si => super::Isotope::Si(super::SiliconIsotope::most_abundant_isotope()),
            Self::P => super::Isotope::P(super::PhosphorusIsotope::most_abundant_isotope()),
            Self::S => super::Isotope::S(super::SulfurIsotope::most_abundant_isotope()),
            Self::Cl => super::Isotope::Cl(super::ChlorineIsotope::most_abundant_isotope()),
            Self::Ar => super::Isotope::Ar(super::ArgonIsotope::most_abundant_isotope()),
            Self::K => super::Isotope::K(super::PotassiumIsotope::most_abundant_isotope()),
            Self::Ca => super::Isotope::Ca(super::CalciumIsotope::most_abundant_isotope()),
            Self::Sc => super::Isotope::Sc(super::ScandiumIsotope::most_abundant_isotope()),
            Self::Ti => super::Isotope::Ti(super::TitaniumIsotope::most_abundant_isotope()),
            Self::V => super::Isotope::V(super::VanadiumIsotope::most_abundant_isotope()),
            Self::Cr => super::Isotope::Cr(super::ChromiumIsotope::most_abundant_isotope()),
            Self::Mn => super::Isotope::Mn(super::ManganeseIsotope::most_abundant_isotope()),
            Self::Fe => super::Isotope::Fe(super::IronIsotope::most_abundant_isotope()),
            Self::Co => super::Isotope::Co(super::CobaltIsotope::most_abundant_isotope()),
            Self::Ni => super::Isotope::Ni(super::NickelIsotope::most_abundant_isotope()),
            Self::Cu => super::Isotope::Cu(super::CopperIsotope::most_abundant_isotope()),
            Self::Zn => super::Isotope::Zn(super::ZincIsotope::most_abundant_isotope()),
            Self::Ga => super::Isotope::Ga(super::GalliumIsotope::most_abundant_isotope()),
            Self::Ge => super::Isotope::Ge(super::GermaniumIsotope::most_abundant_isotope()),
            Self::As => super::Isotope::As(super::ArsenicIsotope::most_abundant_isotope()),
            Self::Se => super::Isotope::Se(super::SeleniumIsotope::most_abundant_isotope()),
            Self::Br => super::Isotope::Br(super::BromineIsotope::most_abundant_isotope()),
            Self::Kr => super::Isotope::Kr(super::KryptonIsotope::most_abundant_isotope()),
            Self::Rb => super::Isotope::Rb(super::RubidiumIsotope::most_abundant_isotope()),
            Self::Sr => super::Isotope::Sr(super::StrontiumIsotope::most_abundant_isotope()),
            Self::Y => super::Isotope::Y(super::YttriumIsotope::most_abundant_isotope()),
            Self::Zr => super::Isotope::Zr(super::ZirconiumIsotope::most_abundant_isotope()),
            Self::Nb => super::Isotope::Nb(super::NiobiumIsotope::most_abundant_isotope()),
            Self::Mo => super::Isotope::Mo(super::MolybdenumIsotope::most_abundant_isotope()),
            Self::Tc => super::Isotope::Tc(super::TechnetiumIsotope::most_abundant_isotope()),
            Self::Ru => super::Isotope::Ru(super::RutheniumIsotope::most_abundant_isotope()),
            Self::Rh => super::Isotope::Rh(super::RhodiumIsotope::most_abundant_isotope()),
            Self::Pd => super::Isotope::Pd(super::PalladiumIsotope::most_abundant_isotope()),
            Self::Ag => super::Isotope::Ag(super::SilverIsotope::most_abundant_isotope()),
            Self::Cd => super::Isotope::Cd(super::CadmiumIsotope::most_abundant_isotope()),
            Self::In => super::Isotope::In(super::IndiumIsotope::most_abundant_isotope()),
            Self::Sn => super::Isotope::Sn(super::TinIsotope::most_abundant_isotope()),
            Self::Sb => super::Isotope::Sb(super::AntimonyIsotope::most_abundant_isotope()),
            Self::Te => super::Isotope::Te(super::TelluriumIsotope::most_abundant_isotope()),
            Self::I => super::Isotope::I(super::IodineIsotope::most_abundant_isotope()),
            Self::Xe => super::Isotope::Xe(super::XenonIsotope::most_abundant_isotope()),
            Self::Cs => super::Isotope::Cs(super::CaesiumIsotope::most_abundant_isotope()),
            Self::Ba => super::Isotope::Ba(super::BariumIsotope::most_abundant_isotope()),
            Self::La => super::Isotope::La(super::LanthanumIsotope::most_abundant_isotope()),
            Self::Ce => super::Isotope::Ce(super::CeriumIsotope::most_abundant_isotope()),
            Self::Pr => super::Isotope::Pr(super::PraseodymiumIsotope::most_abundant_isotope()),
            Self::Nd => super::Isotope::Nd(super::NeodymiumIsotope::most_abundant_isotope()),
            Self::Pm => super::Isotope::Pm(super::PromethiumIsotope::most_abundant_isotope()),
            Self::Sm => super::Isotope::Sm(super::SamariumIsotope::most_abundant_isotope()),
            Self::Eu => super::Isotope::Eu(super::EuropiumIsotope::most_abundant_isotope()),
            Self::Gd => super::Isotope::Gd(super::GadoliniumIsotope::most_abundant_isotope()),
            Self::Tb => super::Isotope::Tb(super::TerbiumIsotope::most_abundant_isotope()),
            Self::Dy => super::Isotope::Dy(super::DysprosiumIsotope::most_abundant_isotope()),
            Self::Ho => super::Isotope::Ho(super::HolmiumIsotope::most_abundant_isotope()),
            Self::Er => super::Isotope::Er(super::ErbiumIsotope::most_abundant_isotope()),
            Self::Tm => super::Isotope::Tm(super::ThuliumIsotope::most_abundant_isotope()),
            Self::Yb => super::Isotope::Yb(super::YtterbiumIsotope::most_abundant_isotope()),
            Self::Lu => super::Isotope::Lu(super::LutetiumIsotope::most_abundant_isotope()),
            Self::Hf => super::Isotope::Hf(super::HafniumIsotope::most_abundant_isotope()),
            Self::Ta => super::Isotope::Ta(super::TantalumIsotope::most_abundant_isotope()),
            Self::W => super::Isotope::W(super::TungstenIsotope::most_abundant_isotope()),
            Self::Re => super::Isotope::Re(super::RheniumIsotope::most_abundant_isotope()),
            Self::Os => super::Isotope::Os(super::OsmiumIsotope::most_abundant_isotope()),
            Self::Ir => super::Isotope::Ir(super::IridiumIsotope::most_abundant_isotope()),
            Self::Pt => super::Isotope::Pt(super::PlatinumIsotope::most_abundant_isotope()),
            Self::Au => super::Isotope::Au(super::GoldIsotope::most_abundant_isotope()),
            Self::Hg => super::Isotope::Hg(super::MercuryIsotope::most_abundant_isotope()),
            Self::Tl => super::Isotope::Tl(super::ThalliumIsotope::most_abundant_isotope()),
            Self::Pb => super::Isotope::Pb(super::LeadIsotope::most_abundant_isotope()),
            Self::Bi => super::Isotope::Bi(super::BismuthIsotope::most_abundant_isotope()),
            Self::Po => super::Isotope::Po(super::PoloniumIsotope::most_abundant_isotope()),
            Self::At => super::Isotope::At(super::AstatineIsotope::most_abundant_isotope()),
            Self::Rn => super::Isotope::Rn(super::RadonIsotope::most_abundant_isotope()),
            Self::Fr => super::Isotope::Fr(super::FranciumIsotope::most_abundant_isotope()),
            Self::Ra => super::Isotope::Ra(super::RadiumIsotope::most_abundant_isotope()),
            Self::Ac => super::Isotope::Ac(super::ActiniumIsotope::most_abundant_isotope()),
            Self::Th => super::Isotope::Th(super::ThoriumIsotope::most_abundant_isotope()),
            Self::Pa => super::Isotope::Pa(super::ProtactiniumIsotope::most_abundant_isotope()),
            Self::U => super::Isotope::U(super::UraniumIsotope::most_abundant_isotope()),
            Self::Np => super::Isotope::Np(super::NeptuniumIsotope::most_abundant_isotope()),
            Self::Pu => super::Isotope::Pu(super::PlutoniumIsotope::most_abundant_isotope()),
            Self::Am => super::Isotope::Am(super::AmericiumIsotope::most_abundant_isotope()),
            Self::Cm => super::Isotope::Cm(super::CuriumIsotope::most_abundant_isotope()),
            Self::Bk => super::Isotope::Bk(super::BerkeliumIsotope::most_abundant_isotope()),
            Self::Cf => super::Isotope::Cf(super::CaliforniumIsotope::most_abundant_isotope()),
            Self::Es => super::Isotope::Es(super::EinsteiniumIsotope::most_abundant_isotope()),
            Self::Fm => super::Isotope::Fm(super::FermiumIsotope::most_abundant_isotope()),
            Self::Md => super::Isotope::Md(super::MendeleviumIsotope::most_abundant_isotope()),
            Self::No => super::Isotope::No(super::NobeliumIsotope::most_abundant_isotope()),
            Self::Lr => super::Isotope::Lr(super::LawrenciumIsotope::most_abundant_isotope()),
            Self::Rf => super::Isotope::Rf(super::RutherfordiumIsotope::most_abundant_isotope()),
            Self::Db => super::Isotope::Db(super::DubniumIsotope::most_abundant_isotope()),
            Self::Sg => super::Isotope::Sg(super::SeaborgiumIsotope::most_abundant_isotope()),
            Self::Bh => super::Isotope::Bh(super::BohriumIsotope::most_abundant_isotope()),
            Self::Hs => super::Isotope::Hs(super::HassiumIsotope::most_abundant_isotope()),
            Self::Mt => super::Isotope::Mt(super::MeitneriumIsotope::most_abundant_isotope()),
            Self::Ds => super::Isotope::Ds(super::DarmstadtiumIsotope::most_abundant_isotope()),
            Self::Rg => super::Isotope::Rg(super::RoentgeniumIsotope::most_abundant_isotope()),
            Self::Cn => super::Isotope::Cn(super::CoperniciumIsotope::most_abundant_isotope()),
            Self::Nh => super::Isotope::Nh(super::NihoniumIsotope::most_abundant_isotope()),
            Self::Fl => super::Isotope::Fl(super::FleroviumIsotope::most_abundant_isotope()),
            Self::Mc => super::Isotope::Mc(super::MoscoviumIsotope::most_abundant_isotope()),
            Self::Lv => super::Isotope::Lv(super::LivermoriumIsotope::most_abundant_isotope()),
            Self::Ts => super::Isotope::Ts(super::TennessineIsotope::most_abundant_isotope()),
            Self::Og => super::Isotope::Og(super::OganessonIsotope::most_abundant_isotope()),
        }
    }
}

#[cfg(test)]
mod tests {
    use strum::IntoEnumIterator;

    use crate::isotopes::ElementVariant;

    #[test]
    fn test_most_abundant_isotope() {
        for element in crate::Element::iter() {
            let isotope = element.most_abundant_isotope();
            // Verify that the returned isotope belongs to the correct element
            assert_eq!(
                isotope.element(),
                element,
                "Most abundant isotope for {element:?} should belong to the same element",
            );
            // Note: Some elements like Tc have no naturally occurring isotopes,
            // so we don't check for isotopic composition here
        }
    }
}