| 1 | use mendeleev::{Element, Isotope}; |
| 2 | |
| 3 | /// For each element, print all its naturally occurring isotopes and their abundance |
| 4 | fn main() { |
| 5 | for element in Element::list() { |
| 6 | print!("{}: ", element.name()); |
| 7 | let isotope_count = Isotope::list() |
| 8 | .iter() |
| 9 | .filter(|isotope| &isotope.element() == element) |
| 10 | .flat_map(|isotope| { |
| 11 | let abundance = isotope.natural_abundance()?; |
| 12 | print!("{}: {}, ", isotope.display_with_superscript(), abundance); |
| 13 | Some(()) |
| 14 | }) |
| 15 | .count(); |
| 16 | if isotope_count == 0 { |
| 17 | print!("No naturally occurring isotopes"); |
| 18 | } |
| 19 | println!(); |
| 20 | } |
| 21 | } |