#[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 ActiniumIsotope {
Ac205,
Ac206,
Ac207,
Ac208,
Ac209,
Ac210,
Ac211,
Ac212,
Ac213,
Ac214,
Ac215,
Ac216,
Ac217,
Ac218,
Ac219,
Ac220,
Ac221,
Ac222,
Ac223,
Ac224,
Ac225,
Ac226,
Ac227,
Ac228,
Ac229,
Ac230,
Ac231,
Ac232,
Ac233,
Ac234,
Ac235,
Ac236,
}
impl super::RelativeAtomicMass for ActiniumIsotope {
#[inline]
fn relative_atomic_mass(&self) -> f64 {
match self {
Self::Ac205 => 205.015144152f64,
Self::Ac206 => 206.014452f64,
Self::Ac207 => 207.011966f64,
Self::Ac208 => 208.01155f64,
Self::Ac209 => 209.009495f64,
Self::Ac210 => 210.009436f64,
Self::Ac211 => 211.007732f64,
Self::Ac212 => 212.007813f64,
Self::Ac213 => 213.006609f64,
Self::Ac214 => 214.006918f64,
Self::Ac215 => 215.006475f64,
Self::Ac216 => 216.008743f64,
Self::Ac217 => 217.009344f64,
Self::Ac218 => 218.011642f64,
Self::Ac219 => 219.012421f64,
Self::Ac220 => 220.0147549f64,
Self::Ac221 => 221.015592f64,
Self::Ac222 => 222.0178442f64,
Self::Ac223 => 223.0191377f64,
Self::Ac224 => 224.0217232f64,
Self::Ac225 => 225.02323f64,
Self::Ac226 => 226.0260984f64,
Self::Ac227 => 227.0277523f64,
Self::Ac228 => 228.0310215f64,
Self::Ac229 => 229.032956f64,
Self::Ac230 => 230.036327f64,
Self::Ac231 => 231.038393f64,
Self::Ac232 => 232.042034f64,
Self::Ac233 => 233.044346f64,
Self::Ac234 => 234.048139f64,
Self::Ac235 => 235.05084f64,
Self::Ac236 => 236.054988f64,
}
}
}
impl super::ElementVariant for ActiniumIsotope {
#[inline]
fn element(&self) -> crate::Element {
crate::Element::Ac
}
}
impl super::MassNumber for ActiniumIsotope {
#[inline]
fn mass_number(&self) -> u16 {
match self {
Self::Ac205 => 205u16,
Self::Ac206 => 206u16,
Self::Ac207 => 207u16,
Self::Ac208 => 208u16,
Self::Ac209 => 209u16,
Self::Ac210 => 210u16,
Self::Ac211 => 211u16,
Self::Ac212 => 212u16,
Self::Ac213 => 213u16,
Self::Ac214 => 214u16,
Self::Ac215 => 215u16,
Self::Ac216 => 216u16,
Self::Ac217 => 217u16,
Self::Ac218 => 218u16,
Self::Ac219 => 219u16,
Self::Ac220 => 220u16,
Self::Ac221 => 221u16,
Self::Ac222 => 222u16,
Self::Ac223 => 223u16,
Self::Ac224 => 224u16,
Self::Ac225 => 225u16,
Self::Ac226 => 226u16,
Self::Ac227 => 227u16,
Self::Ac228 => 228u16,
Self::Ac229 => 229u16,
Self::Ac230 => 230u16,
Self::Ac231 => 231u16,
Self::Ac232 => 232u16,
Self::Ac233 => 233u16,
Self::Ac234 => 234u16,
Self::Ac235 => 235u16,
Self::Ac236 => 236u16,
}
}
}
impl super::IsotopicComposition for ActiniumIsotope {
#[inline]
fn isotopic_composition(&self) -> Option<f64> {
None
}
}
impl super::MostAbundantIsotope for ActiniumIsotope {
fn most_abundant_isotope() -> Self {
Self::Ac236
}
}
impl From<ActiniumIsotope> for crate::Isotope {
fn from(isotope: ActiniumIsotope) -> Self {
crate::Isotope::Ac(isotope)
}
}
impl From<ActiniumIsotope> for crate::Element {
fn from(_isotope: ActiniumIsotope) -> Self {
crate::Element::Ac
}
}
impl TryFrom<u64> for ActiniumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u64) -> Result<Self, Self::Error> {
match value {
205u64 => Ok(Self::Ac205),
206u64 => Ok(Self::Ac206),
207u64 => Ok(Self::Ac207),
208u64 => Ok(Self::Ac208),
209u64 => Ok(Self::Ac209),
210u64 => Ok(Self::Ac210),
211u64 => Ok(Self::Ac211),
212u64 => Ok(Self::Ac212),
213u64 => Ok(Self::Ac213),
214u64 => Ok(Self::Ac214),
215u64 => Ok(Self::Ac215),
216u64 => Ok(Self::Ac216),
217u64 => Ok(Self::Ac217),
218u64 => Ok(Self::Ac218),
219u64 => Ok(Self::Ac219),
220u64 => Ok(Self::Ac220),
221u64 => Ok(Self::Ac221),
222u64 => Ok(Self::Ac222),
223u64 => Ok(Self::Ac223),
224u64 => Ok(Self::Ac224),
225u64 => Ok(Self::Ac225),
226u64 => Ok(Self::Ac226),
227u64 => Ok(Self::Ac227),
228u64 => Ok(Self::Ac228),
229u64 => Ok(Self::Ac229),
230u64 => Ok(Self::Ac230),
231u64 => Ok(Self::Ac231),
232u64 => Ok(Self::Ac232),
233u64 => Ok(Self::Ac233),
234u64 => Ok(Self::Ac234),
235u64 => Ok(Self::Ac235),
236u64 => Ok(Self::Ac236),
_ => Err(crate::errors::Error::Isotope(crate::Element::Ac, value)),
}
}
}
impl TryFrom<u8> for ActiniumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u16> for ActiniumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u16) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u32> for ActiniumIsotope {
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 ActiniumIsotope {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Ac205 => write!(f, "Ac205"),
Self::Ac206 => write!(f, "Ac206"),
Self::Ac207 => write!(f, "Ac207"),
Self::Ac208 => write!(f, "Ac208"),
Self::Ac209 => write!(f, "Ac209"),
Self::Ac210 => write!(f, "Ac210"),
Self::Ac211 => write!(f, "Ac211"),
Self::Ac212 => write!(f, "Ac212"),
Self::Ac213 => write!(f, "Ac213"),
Self::Ac214 => write!(f, "Ac214"),
Self::Ac215 => write!(f, "Ac215"),
Self::Ac216 => write!(f, "Ac216"),
Self::Ac217 => write!(f, "Ac217"),
Self::Ac218 => write!(f, "Ac218"),
Self::Ac219 => write!(f, "Ac219"),
Self::Ac220 => write!(f, "Ac220"),
Self::Ac221 => write!(f, "Ac221"),
Self::Ac222 => write!(f, "Ac222"),
Self::Ac223 => write!(f, "Ac223"),
Self::Ac224 => write!(f, "Ac224"),
Self::Ac225 => write!(f, "Ac225"),
Self::Ac226 => write!(f, "Ac226"),
Self::Ac227 => write!(f, "Ac227"),
Self::Ac228 => write!(f, "Ac228"),
Self::Ac229 => write!(f, "Ac229"),
Self::Ac230 => write!(f, "Ac230"),
Self::Ac231 => write!(f, "Ac231"),
Self::Ac232 => write!(f, "Ac232"),
Self::Ac233 => write!(f, "Ac233"),
Self::Ac234 => write!(f, "Ac234"),
Self::Ac235 => write!(f, "Ac235"),
Self::Ac236 => write!(f, "Ac236"),
}
}
}
#[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 ActiniumIsotope::iter() {
let mass = isotope.relative_atomic_mass();
assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
}
}
#[test]
fn test_element() {
for isotope in ActiniumIsotope::iter() {
let element = isotope.element();
assert_eq!(element, crate::Element::Ac, "Element should be correct for {isotope:?}");
}
}
#[test]
fn test_mass_number() {
for isotope in ActiniumIsotope::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 ActiniumIsotope::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 = ActiniumIsotope::most_abundant_isotope();
let _ = most_abundant.relative_atomic_mass();
}
#[test]
fn test_from_isotope() {
for isotope in ActiniumIsotope::iter() {
let iso: crate::Isotope = isotope.into();
match iso {
crate::Isotope::Ac(i) => assert_eq!(i, isotope),
_ => panic!("Wrong isotope type"),
}
}
}
#[test]
fn test_from_element() {
for isotope in ActiniumIsotope::iter() {
let elem: crate::Element = isotope.into();
assert_eq!(elem, crate::Element::Ac);
}
}
#[test]
fn test_try_from_mass_number() {
for isotope in ActiniumIsotope::iter() {
let mass = isotope.mass_number();
let iso = ActiniumIsotope::try_from(mass).unwrap();
assert_eq!(iso, isotope);
let iso_u32 = ActiniumIsotope::try_from(u32::from(mass)).unwrap();
assert_eq!(iso_u32, isotope);
if let Ok(mass_u8) = u8::try_from(mass) {
let iso_u8 = ActiniumIsotope::try_from(mass_u8).unwrap();
assert_eq!(iso_u8, isotope);
}
}
assert!(ActiniumIsotope::try_from(0_u16).is_err());
assert!(ActiniumIsotope::try_from(1000_u16).is_err());
assert!(ActiniumIsotope::try_from(0_u32).is_err());
assert!(ActiniumIsotope::try_from(1000_u32).is_err());
assert!(ActiniumIsotope::try_from(0_u8).is_err());
}
#[test]
fn test_display() {
for isotope in ActiniumIsotope::iter() {
let s = alloc::format!("{isotope}");
assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
}
}
}