#[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 AstatineIsotope {
At191,
At192,
At193,
At194,
At195,
At196,
At197,
At198,
At199,
At200,
At201,
At202,
At203,
At204,
At205,
At206,
At207,
At208,
At209,
At210,
At211,
At212,
At213,
At214,
At215,
At216,
At217,
At218,
At219,
At220,
At221,
At222,
At223,
At224,
At225,
At226,
At227,
At228,
At229,
}
impl super::RelativeAtomicMass for AstatineIsotope {
#[inline]
fn relative_atomic_mass(&self) -> f64 {
match self {
Self::At191 => 191.004148f64,
Self::At192 => 192.003152f64,
Self::At193 => 192.999927f64,
Self::At194 => 193.999236f64,
Self::At195 => 194.9962685f64,
Self::At196 => 195.9958f64,
Self::At197 => 196.993189f64,
Self::At198 => 197.992784f64,
Self::At199 => 198.9905277f64,
Self::At200 => 199.990351f64,
Self::At201 => 200.9884171f64,
Self::At202 => 201.98863f64,
Self::At203 => 202.986943f64,
Self::At204 => 203.987251f64,
Self::At205 => 204.986076f64,
Self::At206 => 205.986657f64,
Self::At207 => 206.9858f64,
Self::At208 => 207.9866133f64,
Self::At209 => 208.9861702f64,
Self::At210 => 209.9871479f64,
Self::At211 => 210.9874966f64,
Self::At212 => 211.9907377f64,
Self::At213 => 212.992937f64,
Self::At214 => 213.9963721f64,
Self::At215 => 214.9986528f64,
Self::At216 => 216.0024236f64,
Self::At217 => 217.0047192f64,
Self::At218 => 218.008695f64,
Self::At219 => 219.0111618f64,
Self::At220 => 220.015433f64,
Self::At221 => 221.018017f64,
Self::At222 => 222.022494f64,
Self::At223 => 223.025151f64,
Self::At224 => 224.029749f64,
Self::At225 => 225.03263f64,
Self::At226 => 226.03716f64,
Self::At227 => 227.04024f64,
Self::At228 => 228.04475f64,
Self::At229 => 229.04812f64,
}
}
}
impl super::ElementVariant for AstatineIsotope {
#[inline]
fn element(&self) -> crate::Element {
crate::Element::At
}
}
impl super::MassNumber for AstatineIsotope {
#[inline]
fn mass_number(&self) -> u16 {
match self {
Self::At191 => 191u16,
Self::At192 => 192u16,
Self::At193 => 193u16,
Self::At194 => 194u16,
Self::At195 => 195u16,
Self::At196 => 196u16,
Self::At197 => 197u16,
Self::At198 => 198u16,
Self::At199 => 199u16,
Self::At200 => 200u16,
Self::At201 => 201u16,
Self::At202 => 202u16,
Self::At203 => 203u16,
Self::At204 => 204u16,
Self::At205 => 205u16,
Self::At206 => 206u16,
Self::At207 => 207u16,
Self::At208 => 208u16,
Self::At209 => 209u16,
Self::At210 => 210u16,
Self::At211 => 211u16,
Self::At212 => 212u16,
Self::At213 => 213u16,
Self::At214 => 214u16,
Self::At215 => 215u16,
Self::At216 => 216u16,
Self::At217 => 217u16,
Self::At218 => 218u16,
Self::At219 => 219u16,
Self::At220 => 220u16,
Self::At221 => 221u16,
Self::At222 => 222u16,
Self::At223 => 223u16,
Self::At224 => 224u16,
Self::At225 => 225u16,
Self::At226 => 226u16,
Self::At227 => 227u16,
Self::At228 => 228u16,
Self::At229 => 229u16,
}
}
}
impl super::IsotopicComposition for AstatineIsotope {
#[inline]
fn isotopic_composition(&self) -> Option<f64> {
None
}
}
impl super::MostAbundantIsotope for AstatineIsotope {
fn most_abundant_isotope() -> Self {
Self::At229
}
}
impl From<AstatineIsotope> for crate::Isotope {
fn from(isotope: AstatineIsotope) -> Self {
crate::Isotope::At(isotope)
}
}
impl From<AstatineIsotope> for crate::Element {
fn from(_isotope: AstatineIsotope) -> Self {
crate::Element::At
}
}
impl TryFrom<u64> for AstatineIsotope {
type Error = crate::errors::Error;
fn try_from(value: u64) -> Result<Self, Self::Error> {
match value {
191u64 => Ok(Self::At191),
192u64 => Ok(Self::At192),
193u64 => Ok(Self::At193),
194u64 => Ok(Self::At194),
195u64 => Ok(Self::At195),
196u64 => Ok(Self::At196),
197u64 => Ok(Self::At197),
198u64 => Ok(Self::At198),
199u64 => Ok(Self::At199),
200u64 => Ok(Self::At200),
201u64 => Ok(Self::At201),
202u64 => Ok(Self::At202),
203u64 => Ok(Self::At203),
204u64 => Ok(Self::At204),
205u64 => Ok(Self::At205),
206u64 => Ok(Self::At206),
207u64 => Ok(Self::At207),
208u64 => Ok(Self::At208),
209u64 => Ok(Self::At209),
210u64 => Ok(Self::At210),
211u64 => Ok(Self::At211),
212u64 => Ok(Self::At212),
213u64 => Ok(Self::At213),
214u64 => Ok(Self::At214),
215u64 => Ok(Self::At215),
216u64 => Ok(Self::At216),
217u64 => Ok(Self::At217),
218u64 => Ok(Self::At218),
219u64 => Ok(Self::At219),
220u64 => Ok(Self::At220),
221u64 => Ok(Self::At221),
222u64 => Ok(Self::At222),
223u64 => Ok(Self::At223),
224u64 => Ok(Self::At224),
225u64 => Ok(Self::At225),
226u64 => Ok(Self::At226),
227u64 => Ok(Self::At227),
228u64 => Ok(Self::At228),
229u64 => Ok(Self::At229),
_ => Err(crate::errors::Error::Isotope(crate::Element::At, value)),
}
}
}
impl TryFrom<u8> for AstatineIsotope {
type Error = crate::errors::Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u16> for AstatineIsotope {
type Error = crate::errors::Error;
fn try_from(value: u16) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u32> for AstatineIsotope {
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 AstatineIsotope {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::At191 => write!(f, "At191"),
Self::At192 => write!(f, "At192"),
Self::At193 => write!(f, "At193"),
Self::At194 => write!(f, "At194"),
Self::At195 => write!(f, "At195"),
Self::At196 => write!(f, "At196"),
Self::At197 => write!(f, "At197"),
Self::At198 => write!(f, "At198"),
Self::At199 => write!(f, "At199"),
Self::At200 => write!(f, "At200"),
Self::At201 => write!(f, "At201"),
Self::At202 => write!(f, "At202"),
Self::At203 => write!(f, "At203"),
Self::At204 => write!(f, "At204"),
Self::At205 => write!(f, "At205"),
Self::At206 => write!(f, "At206"),
Self::At207 => write!(f, "At207"),
Self::At208 => write!(f, "At208"),
Self::At209 => write!(f, "At209"),
Self::At210 => write!(f, "At210"),
Self::At211 => write!(f, "At211"),
Self::At212 => write!(f, "At212"),
Self::At213 => write!(f, "At213"),
Self::At214 => write!(f, "At214"),
Self::At215 => write!(f, "At215"),
Self::At216 => write!(f, "At216"),
Self::At217 => write!(f, "At217"),
Self::At218 => write!(f, "At218"),
Self::At219 => write!(f, "At219"),
Self::At220 => write!(f, "At220"),
Self::At221 => write!(f, "At221"),
Self::At222 => write!(f, "At222"),
Self::At223 => write!(f, "At223"),
Self::At224 => write!(f, "At224"),
Self::At225 => write!(f, "At225"),
Self::At226 => write!(f, "At226"),
Self::At227 => write!(f, "At227"),
Self::At228 => write!(f, "At228"),
Self::At229 => write!(f, "At229"),
}
}
}
#[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 AstatineIsotope::iter() {
let mass = isotope.relative_atomic_mass();
assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
}
}
#[test]
fn test_element() {
for isotope in AstatineIsotope::iter() {
let element = isotope.element();
assert_eq!(element, crate::Element::At, "Element should be correct for {isotope:?}");
}
}
#[test]
fn test_mass_number() {
for isotope in AstatineIsotope::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 AstatineIsotope::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 = AstatineIsotope::most_abundant_isotope();
let _ = most_abundant.relative_atomic_mass();
}
#[test]
fn test_from_isotope() {
for isotope in AstatineIsotope::iter() {
let iso: crate::Isotope = isotope.into();
match iso {
crate::Isotope::At(i) => assert_eq!(i, isotope),
_ => panic!("Wrong isotope type"),
}
}
}
#[test]
fn test_from_element() {
for isotope in AstatineIsotope::iter() {
let elem: crate::Element = isotope.into();
assert_eq!(elem, crate::Element::At);
}
}
#[test]
fn test_try_from_mass_number() {
for isotope in AstatineIsotope::iter() {
let mass = isotope.mass_number();
let iso = AstatineIsotope::try_from(mass).unwrap();
assert_eq!(iso, isotope);
let iso_u32 = AstatineIsotope::try_from(u32::from(mass)).unwrap();
assert_eq!(iso_u32, isotope);
if let Ok(mass_u8) = u8::try_from(mass) {
let iso_u8 = AstatineIsotope::try_from(mass_u8).unwrap();
assert_eq!(iso_u8, isotope);
}
}
assert!(AstatineIsotope::try_from(0_u16).is_err());
assert!(AstatineIsotope::try_from(1000_u16).is_err());
assert!(AstatineIsotope::try_from(0_u32).is_err());
assert!(AstatineIsotope::try_from(1000_u32).is_err());
assert!(AstatineIsotope::try_from(0_u8).is_err());
}
#[test]
fn test_display() {
for isotope in AstatineIsotope::iter() {
let s = alloc::format!("{isotope}");
assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
}
}
}