| 1 | use superrust-analyzer cargo mendeleev 0.8.1 properties/isotopes/::Isotoperust-analyzer cargo mendeleev 0.8.1 isotope/Isotope#; |
| 2 | |
| 3 | #[cfg(feature = "ranges")] |
| 4 | /// Range from the minimum to the maximum neutron number across all isotopes |
| 5 | /// |
| 6 | /// Convenience constant to avoid writing the code below when this range is needed: |
| 7 | /// |
| 8 | /// ``` |
| 9 | /// use mendeleev::{Isotope, ISOTOPE_NEUTRON_NUMBER_RANGE}; |
| 10 | /// let all_values = Isotope::iter().map(|e| e.neutron_number()); |
| 11 | /// let min = all_values.clone().min().unwrap(); |
| 12 | /// let max = all_values.max().unwrap(); |
| 13 | /// assert_eq!(min..=max, ISOTOPE_NEUTRON_NUMBER_RANGE); |
| 14 | /// ``` |
| 15 | pub const ISOTOPE_NEUTRON_NUMBER_RANGErust-analyzer cargo mendeleev 0.8.1 properties/isotopes/neutron_number/ISOTOPE_NEUTRON_NUMBER_RANGE.: corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<u32> = 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#177; |
| 16 | |
| 17 | impl Isotoperust-analyzer cargo mendeleev 0.8.1 isotope/Isotope# { |
| 18 | /// Returns the neutron number of the isotope, |
| 19 | /// i.e., the number of neutrons in its nucleus |
| 20 | /// |
| 21 | /// ``` |
| 22 | /// use mendeleev::Isotope; |
| 23 | /// assert_eq!(Isotope::H1.neutron_number(), 0); |
| 24 | /// assert_eq!(Isotope::Og295.neutron_number(), 177); |
| 25 | /// ``` |
| 26 | pub const fn neutron_numberrust-analyzer cargo mendeleev 0.8.1 properties/isotopes/neutron_number/impl#[Isotope]neutron_number().(&self) -> u32 { |
| 27 | self.mass_numberrust-analyzer cargo mendeleev 0.8.1 properties/isotopes/mass_number/impl#[Isotope]mass_number().() |
| 28 | .saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]saturating_sub().(self.elementrust-analyzer cargo mendeleev 0.8.1 properties/isotopes/element/impl#[Isotope]element().().atomic_numberrust-analyzer cargo mendeleev 0.8.1 properties/atomic_number/impl#[Element]atomic_number().()) |
| 29 | } |
| 30 | } |