#[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 IndiumIsotope {
In96,
In97,
In98,
In99,
In100,
In101,
In102,
In103,
In104,
In105,
In106,
In107,
In108,
In109,
In110,
In111,
In112,
In113,
In114,
In115,
In116,
In117,
In118,
In119,
In120,
In121,
In122,
In123,
In124,
In125,
In126,
In127,
In128,
In129,
In130,
In131,
In132,
In133,
In134,
In135,
In136,
In137,
}
impl super::RelativeAtomicMass for IndiumIsotope {
#[inline]
fn relative_atomic_mass(&self) -> f64 {
match self {
Self::In96 => 95.959109f64,
Self::In97 => 96.94934f64,
Self::In98 => 97.94214f64,
Self::In99 => 98.93411f64,
Self::In100 => 99.93096f64,
Self::In101 => 100.92634f64,
Self::In102 => 101.9241071f64,
Self::In103 => 102.9198819f64,
Self::In104 => 103.9182145f64,
Self::In105 => 104.914502f64,
Self::In106 => 105.913464f64,
Self::In107 => 106.91029f64,
Self::In108 => 107.9096935f64,
Self::In109 => 108.9071514f64,
Self::In110 => 109.90717f64,
Self::In111 => 110.9051085f64,
Self::In112 => 111.9055377f64,
Self::In113 => 112.90406184f64,
Self::In114 => 113.90491791f64,
Self::In115 => 114.903878776f64,
Self::In116 => 115.90525999f64,
Self::In117 => 116.9045157f64,
Self::In118 => 117.9063566f64,
Self::In119 => 118.9058507f64,
Self::In120 => 119.907967f64,
Self::In121 => 120.907851f64,
Self::In122 => 121.910281f64,
Self::In123 => 122.910434f64,
Self::In124 => 123.913182f64,
Self::In125 => 124.913605f64,
Self::In126 => 125.916507f64,
Self::In127 => 126.917446f64,
Self::In128 => 127.9204f64,
Self::In129 => 128.9218053f64,
Self::In130 => 129.924977f64,
Self::In131 => 130.9269715f64,
Self::In132 => 131.933001f64,
Self::In133 => 132.93831f64,
Self::In134 => 133.94454f64,
Self::In135 => 134.95005f64,
Self::In136 => 135.956017f64,
Self::In137 => 136.961535f64,
}
}
}
impl super::ElementVariant for IndiumIsotope {
#[inline]
fn element(&self) -> crate::Element {
crate::Element::In
}
}
impl super::MassNumber for IndiumIsotope {
#[inline]
fn mass_number(&self) -> u16 {
match self {
Self::In96 => 96u16,
Self::In97 => 97u16,
Self::In98 => 98u16,
Self::In99 => 99u16,
Self::In100 => 100u16,
Self::In101 => 101u16,
Self::In102 => 102u16,
Self::In103 => 103u16,
Self::In104 => 104u16,
Self::In105 => 105u16,
Self::In106 => 106u16,
Self::In107 => 107u16,
Self::In108 => 108u16,
Self::In109 => 109u16,
Self::In110 => 110u16,
Self::In111 => 111u16,
Self::In112 => 112u16,
Self::In113 => 113u16,
Self::In114 => 114u16,
Self::In115 => 115u16,
Self::In116 => 116u16,
Self::In117 => 117u16,
Self::In118 => 118u16,
Self::In119 => 119u16,
Self::In120 => 120u16,
Self::In121 => 121u16,
Self::In122 => 122u16,
Self::In123 => 123u16,
Self::In124 => 124u16,
Self::In125 => 125u16,
Self::In126 => 126u16,
Self::In127 => 127u16,
Self::In128 => 128u16,
Self::In129 => 129u16,
Self::In130 => 130u16,
Self::In131 => 131u16,
Self::In132 => 132u16,
Self::In133 => 133u16,
Self::In134 => 134u16,
Self::In135 => 135u16,
Self::In136 => 136u16,
Self::In137 => 137u16,
}
}
}
impl super::IsotopicComposition for IndiumIsotope {
#[inline]
fn isotopic_composition(&self) -> Option<f64> {
match self {
Self::In113 => Some(0.0429f64),
Self::In115 => Some(0.9571f64),
_ => None,
}
}
}
impl super::MostAbundantIsotope for IndiumIsotope {
fn most_abundant_isotope() -> Self {
Self::In115
}
}
impl From<IndiumIsotope> for crate::Isotope {
fn from(isotope: IndiumIsotope) -> Self {
crate::Isotope::In(isotope)
}
}
impl From<IndiumIsotope> for crate::Element {
fn from(_isotope: IndiumIsotope) -> Self {
crate::Element::In
}
}
impl TryFrom<u64> for IndiumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u64) -> Result<Self, Self::Error> {
match value {
96u64 => Ok(Self::In96),
97u64 => Ok(Self::In97),
98u64 => Ok(Self::In98),
99u64 => Ok(Self::In99),
100u64 => Ok(Self::In100),
101u64 => Ok(Self::In101),
102u64 => Ok(Self::In102),
103u64 => Ok(Self::In103),
104u64 => Ok(Self::In104),
105u64 => Ok(Self::In105),
106u64 => Ok(Self::In106),
107u64 => Ok(Self::In107),
108u64 => Ok(Self::In108),
109u64 => Ok(Self::In109),
110u64 => Ok(Self::In110),
111u64 => Ok(Self::In111),
112u64 => Ok(Self::In112),
113u64 => Ok(Self::In113),
114u64 => Ok(Self::In114),
115u64 => Ok(Self::In115),
116u64 => Ok(Self::In116),
117u64 => Ok(Self::In117),
118u64 => Ok(Self::In118),
119u64 => Ok(Self::In119),
120u64 => Ok(Self::In120),
121u64 => Ok(Self::In121),
122u64 => Ok(Self::In122),
123u64 => Ok(Self::In123),
124u64 => Ok(Self::In124),
125u64 => Ok(Self::In125),
126u64 => Ok(Self::In126),
127u64 => Ok(Self::In127),
128u64 => Ok(Self::In128),
129u64 => Ok(Self::In129),
130u64 => Ok(Self::In130),
131u64 => Ok(Self::In131),
132u64 => Ok(Self::In132),
133u64 => Ok(Self::In133),
134u64 => Ok(Self::In134),
135u64 => Ok(Self::In135),
136u64 => Ok(Self::In136),
137u64 => Ok(Self::In137),
_ => Err(crate::errors::Error::Isotope(crate::Element::In, value)),
}
}
}
impl TryFrom<u8> for IndiumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u16> for IndiumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u16) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u32> for IndiumIsotope {
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 IndiumIsotope {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::In96 => write!(f, "In96"),
Self::In97 => write!(f, "In97"),
Self::In98 => write!(f, "In98"),
Self::In99 => write!(f, "In99"),
Self::In100 => write!(f, "In100"),
Self::In101 => write!(f, "In101"),
Self::In102 => write!(f, "In102"),
Self::In103 => write!(f, "In103"),
Self::In104 => write!(f, "In104"),
Self::In105 => write!(f, "In105"),
Self::In106 => write!(f, "In106"),
Self::In107 => write!(f, "In107"),
Self::In108 => write!(f, "In108"),
Self::In109 => write!(f, "In109"),
Self::In110 => write!(f, "In110"),
Self::In111 => write!(f, "In111"),
Self::In112 => write!(f, "In112"),
Self::In113 => write!(f, "In113"),
Self::In114 => write!(f, "In114"),
Self::In115 => write!(f, "In115"),
Self::In116 => write!(f, "In116"),
Self::In117 => write!(f, "In117"),
Self::In118 => write!(f, "In118"),
Self::In119 => write!(f, "In119"),
Self::In120 => write!(f, "In120"),
Self::In121 => write!(f, "In121"),
Self::In122 => write!(f, "In122"),
Self::In123 => write!(f, "In123"),
Self::In124 => write!(f, "In124"),
Self::In125 => write!(f, "In125"),
Self::In126 => write!(f, "In126"),
Self::In127 => write!(f, "In127"),
Self::In128 => write!(f, "In128"),
Self::In129 => write!(f, "In129"),
Self::In130 => write!(f, "In130"),
Self::In131 => write!(f, "In131"),
Self::In132 => write!(f, "In132"),
Self::In133 => write!(f, "In133"),
Self::In134 => write!(f, "In134"),
Self::In135 => write!(f, "In135"),
Self::In136 => write!(f, "In136"),
Self::In137 => write!(f, "In137"),
}
}
}
#[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 IndiumIsotope::iter() {
let mass = isotope.relative_atomic_mass();
assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
}
}
#[test]
fn test_element() {
for isotope in IndiumIsotope::iter() {
let element = isotope.element();
assert_eq!(element, crate::Element::In, "Element should be correct for {isotope:?}");
}
}
#[test]
fn test_mass_number() {
for isotope in IndiumIsotope::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 IndiumIsotope::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 = IndiumIsotope::most_abundant_isotope();
let _ = most_abundant.relative_atomic_mass();
}
#[test]
fn test_from_isotope() {
for isotope in IndiumIsotope::iter() {
let iso: crate::Isotope = isotope.into();
match iso {
crate::Isotope::In(i) => assert_eq!(i, isotope),
_ => panic!("Wrong isotope type"),
}
}
}
#[test]
fn test_from_element() {
for isotope in IndiumIsotope::iter() {
let elem: crate::Element = isotope.into();
assert_eq!(elem, crate::Element::In);
}
}
#[test]
fn test_try_from_mass_number() {
for isotope in IndiumIsotope::iter() {
let mass = isotope.mass_number();
let iso = IndiumIsotope::try_from(mass).unwrap();
assert_eq!(iso, isotope);
let iso_u32 = IndiumIsotope::try_from(u32::from(mass)).unwrap();
assert_eq!(iso_u32, isotope);
if let Ok(mass_u8) = u8::try_from(mass) {
let iso_u8 = IndiumIsotope::try_from(mass_u8).unwrap();
assert_eq!(iso_u8, isotope);
}
}
assert!(IndiumIsotope::try_from(0_u16).is_err());
assert!(IndiumIsotope::try_from(1000_u16).is_err());
assert!(IndiumIsotope::try_from(0_u32).is_err());
assert!(IndiumIsotope::try_from(1000_u32).is_err());
assert!(IndiumIsotope::try_from(0_u8).is_err());
}
#[test]
fn test_display() {
for isotope in IndiumIsotope::iter() {
let s = alloc::format!("{isotope}");
assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
}
}
}