#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, strum :: EnumIter)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "mem_size", derive(mem_dbg::MemSize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemDbg))]
#[cfg_attr(feature = "mem_size", mem_size(flat))]
pub enum EuropiumIsotope {
Eu130,
Eu131,
Eu132,
Eu133,
Eu134,
Eu135,
Eu136,
Eu137,
Eu138,
Eu139,
Eu140,
Eu141,
Eu142,
Eu143,
Eu144,
Eu145,
Eu146,
Eu147,
Eu148,
Eu149,
Eu150,
Eu151,
Eu152,
Eu153,
Eu154,
Eu155,
Eu156,
Eu157,
Eu158,
Eu159,
Eu160,
Eu161,
Eu162,
Eu163,
Eu164,
Eu165,
Eu166,
Eu167,
Eu168,
Eu169,
}
impl super::RelativeAtomicMass for EuropiumIsotope {
#[inline]
fn relative_atomic_mass(&self) -> f64 {
match self {
Self::Eu130 => 129.96369f64,
Self::Eu131 => 130.95784f64,
Self::Eu132 => 131.95467f64,
Self::Eu133 => 132.94929f64,
Self::Eu134 => 133.9464f64,
Self::Eu135 => 134.94187f64,
Self::Eu136 => 135.93962f64,
Self::Eu137 => 136.93546f64,
Self::Eu138 => 137.933709f64,
Self::Eu139 => 138.929792f64,
Self::Eu140 => 139.928088f64,
Self::Eu141 => 140.924932f64,
Self::Eu142 => 141.923442f64,
Self::Eu143 => 142.920299f64,
Self::Eu144 => 143.91882f64,
Self::Eu145 => 144.9162726f64,
Self::Eu146 => 145.917211f64,
Self::Eu147 => 146.9167527f64,
Self::Eu148 => 147.918089f64,
Self::Eu149 => 148.9179378f64,
Self::Eu150 => 149.9197077f64,
Self::Eu151 => 150.9198578f64,
Self::Eu152 => 151.9217522f64,
Self::Eu153 => 152.921238f64,
Self::Eu154 => 153.922987f64,
Self::Eu155 => 154.9229011f64,
Self::Eu156 => 155.9247605f64,
Self::Eu157 => 156.9254334f64,
Self::Eu158 => 157.927799f64,
Self::Eu159 => 158.9291001f64,
Self::Eu160 => 159.931851f64,
Self::Eu161 => 160.933664f64,
Self::Eu162 => 161.936989f64,
Self::Eu163 => 162.939196f64,
Self::Eu164 => 163.94274f64,
Self::Eu165 => 164.94559f64,
Self::Eu166 => 165.94962f64,
Self::Eu167 => 166.95289f64,
Self::Eu168 => 167.957863f64,
Self::Eu169 => 168.961717f64,
}
}
}
impl super::ElementVariant for EuropiumIsotope {
#[inline]
fn element(&self) -> crate::Element {
crate::Element::Eu
}
}
impl super::MassNumber for EuropiumIsotope {
#[inline]
fn mass_number(&self) -> u16 {
match self {
Self::Eu130 => 130u16,
Self::Eu131 => 131u16,
Self::Eu132 => 132u16,
Self::Eu133 => 133u16,
Self::Eu134 => 134u16,
Self::Eu135 => 135u16,
Self::Eu136 => 136u16,
Self::Eu137 => 137u16,
Self::Eu138 => 138u16,
Self::Eu139 => 139u16,
Self::Eu140 => 140u16,
Self::Eu141 => 141u16,
Self::Eu142 => 142u16,
Self::Eu143 => 143u16,
Self::Eu144 => 144u16,
Self::Eu145 => 145u16,
Self::Eu146 => 146u16,
Self::Eu147 => 147u16,
Self::Eu148 => 148u16,
Self::Eu149 => 149u16,
Self::Eu150 => 150u16,
Self::Eu151 => 151u16,
Self::Eu152 => 152u16,
Self::Eu153 => 153u16,
Self::Eu154 => 154u16,
Self::Eu155 => 155u16,
Self::Eu156 => 156u16,
Self::Eu157 => 157u16,
Self::Eu158 => 158u16,
Self::Eu159 => 159u16,
Self::Eu160 => 160u16,
Self::Eu161 => 161u16,
Self::Eu162 => 162u16,
Self::Eu163 => 163u16,
Self::Eu164 => 164u16,
Self::Eu165 => 165u16,
Self::Eu166 => 166u16,
Self::Eu167 => 167u16,
Self::Eu168 => 168u16,
Self::Eu169 => 169u16,
}
}
}
impl super::IsotopicComposition for EuropiumIsotope {
#[inline]
fn isotopic_composition(&self) -> Option<f64> {
match self {
Self::Eu151 => Some(0.4781f64),
Self::Eu153 => Some(0.5219f64),
_ => None,
}
}
}
impl super::MostAbundantIsotope for EuropiumIsotope {
fn most_abundant_isotope() -> Self {
Self::Eu153
}
}
impl From<EuropiumIsotope> for crate::Isotope {
fn from(isotope: EuropiumIsotope) -> Self {
crate::Isotope::Eu(isotope)
}
}
impl From<EuropiumIsotope> for crate::Element {
fn from(_isotope: EuropiumIsotope) -> Self {
crate::Element::Eu
}
}
impl TryFrom<u64> for EuropiumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u64) -> Result<Self, Self::Error> {
match value {
130u64 => Ok(Self::Eu130),
131u64 => Ok(Self::Eu131),
132u64 => Ok(Self::Eu132),
133u64 => Ok(Self::Eu133),
134u64 => Ok(Self::Eu134),
135u64 => Ok(Self::Eu135),
136u64 => Ok(Self::Eu136),
137u64 => Ok(Self::Eu137),
138u64 => Ok(Self::Eu138),
139u64 => Ok(Self::Eu139),
140u64 => Ok(Self::Eu140),
141u64 => Ok(Self::Eu141),
142u64 => Ok(Self::Eu142),
143u64 => Ok(Self::Eu143),
144u64 => Ok(Self::Eu144),
145u64 => Ok(Self::Eu145),
146u64 => Ok(Self::Eu146),
147u64 => Ok(Self::Eu147),
148u64 => Ok(Self::Eu148),
149u64 => Ok(Self::Eu149),
150u64 => Ok(Self::Eu150),
151u64 => Ok(Self::Eu151),
152u64 => Ok(Self::Eu152),
153u64 => Ok(Self::Eu153),
154u64 => Ok(Self::Eu154),
155u64 => Ok(Self::Eu155),
156u64 => Ok(Self::Eu156),
157u64 => Ok(Self::Eu157),
158u64 => Ok(Self::Eu158),
159u64 => Ok(Self::Eu159),
160u64 => Ok(Self::Eu160),
161u64 => Ok(Self::Eu161),
162u64 => Ok(Self::Eu162),
163u64 => Ok(Self::Eu163),
164u64 => Ok(Self::Eu164),
165u64 => Ok(Self::Eu165),
166u64 => Ok(Self::Eu166),
167u64 => Ok(Self::Eu167),
168u64 => Ok(Self::Eu168),
169u64 => Ok(Self::Eu169),
_ => Err(crate::errors::Error::Isotope(crate::Element::Eu, value)),
}
}
}
impl TryFrom<u8> for EuropiumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u16> for EuropiumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u16) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u32> for EuropiumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u32) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl core::fmt::Display for EuropiumIsotope {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Eu130 => write!(f, "Eu130"),
Self::Eu131 => write!(f, "Eu131"),
Self::Eu132 => write!(f, "Eu132"),
Self::Eu133 => write!(f, "Eu133"),
Self::Eu134 => write!(f, "Eu134"),
Self::Eu135 => write!(f, "Eu135"),
Self::Eu136 => write!(f, "Eu136"),
Self::Eu137 => write!(f, "Eu137"),
Self::Eu138 => write!(f, "Eu138"),
Self::Eu139 => write!(f, "Eu139"),
Self::Eu140 => write!(f, "Eu140"),
Self::Eu141 => write!(f, "Eu141"),
Self::Eu142 => write!(f, "Eu142"),
Self::Eu143 => write!(f, "Eu143"),
Self::Eu144 => write!(f, "Eu144"),
Self::Eu145 => write!(f, "Eu145"),
Self::Eu146 => write!(f, "Eu146"),
Self::Eu147 => write!(f, "Eu147"),
Self::Eu148 => write!(f, "Eu148"),
Self::Eu149 => write!(f, "Eu149"),
Self::Eu150 => write!(f, "Eu150"),
Self::Eu151 => write!(f, "Eu151"),
Self::Eu152 => write!(f, "Eu152"),
Self::Eu153 => write!(f, "Eu153"),
Self::Eu154 => write!(f, "Eu154"),
Self::Eu155 => write!(f, "Eu155"),
Self::Eu156 => write!(f, "Eu156"),
Self::Eu157 => write!(f, "Eu157"),
Self::Eu158 => write!(f, "Eu158"),
Self::Eu159 => write!(f, "Eu159"),
Self::Eu160 => write!(f, "Eu160"),
Self::Eu161 => write!(f, "Eu161"),
Self::Eu162 => write!(f, "Eu162"),
Self::Eu163 => write!(f, "Eu163"),
Self::Eu164 => write!(f, "Eu164"),
Self::Eu165 => write!(f, "Eu165"),
Self::Eu166 => write!(f, "Eu166"),
Self::Eu167 => write!(f, "Eu167"),
Self::Eu168 => write!(f, "Eu168"),
Self::Eu169 => write!(f, "Eu169"),
}
}
}
#[cfg(test)]
mod tests {
use strum::IntoEnumIterator;
use super::*;
use crate::isotopes::{
ElementVariant, IsotopicComposition, MassNumber, MostAbundantIsotope, RelativeAtomicMass,
};
#[test]
fn test_relative_atomic_mass() {
for isotope in EuropiumIsotope::iter() {
let mass = isotope.relative_atomic_mass();
assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
}
}
#[test]
fn test_element() {
for isotope in EuropiumIsotope::iter() {
let element = isotope.element();
assert_eq!(element, crate::Element::Eu, "Element should be correct for {isotope:?}");
}
}
#[test]
fn test_mass_number() {
for isotope in EuropiumIsotope::iter() {
let mass_number = isotope.mass_number();
assert!(
mass_number > 0 && mass_number < 300,
"Mass number should be reasonable for {isotope:?}"
);
}
}
#[test]
fn test_isotopic_composition() {
for isotope in EuropiumIsotope::iter() {
let comp = isotope.isotopic_composition();
if let Some(c) = comp {
assert!(
(0.0..=1.0).contains(&c),
"Composition should be between 0 and 1 for {isotope:?}"
);
}
}
}
#[test]
fn test_most_abundant() {
let most_abundant = EuropiumIsotope::most_abundant_isotope();
let _ = most_abundant.relative_atomic_mass();
}
#[test]
fn test_from_isotope() {
for isotope in EuropiumIsotope::iter() {
let iso: crate::Isotope = isotope.into();
match iso {
crate::Isotope::Eu(i) => assert_eq!(i, isotope),
_ => panic!("Wrong isotope type"),
}
}
}
#[test]
fn test_from_element() {
for isotope in EuropiumIsotope::iter() {
let elem: crate::Element = isotope.into();
assert_eq!(elem, crate::Element::Eu);
}
}
#[test]
fn test_try_from_mass_number() {
for isotope in EuropiumIsotope::iter() {
let mass = isotope.mass_number();
let iso = EuropiumIsotope::try_from(mass).unwrap();
assert_eq!(iso, isotope);
let iso_u32 = EuropiumIsotope::try_from(u32::from(mass)).unwrap();
assert_eq!(iso_u32, isotope);
if let Ok(mass_u8) = u8::try_from(mass) {
let iso_u8 = EuropiumIsotope::try_from(mass_u8).unwrap();
assert_eq!(iso_u8, isotope);
}
}
assert!(EuropiumIsotope::try_from(0_u16).is_err());
assert!(EuropiumIsotope::try_from(1000_u16).is_err());
assert!(EuropiumIsotope::try_from(0_u32).is_err());
assert!(EuropiumIsotope::try_from(1000_u32).is_err());
assert!(EuropiumIsotope::try_from(0_u8).is_err());
}
#[test]
fn test_display() {
for isotope in EuropiumIsotope::iter() {
let s = alloc::format!("{isotope}");
assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
}
}
}