| 1 | use mendeleevrust-analyzer cargo mendeleev 0.8.1 crate/::Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#; |
| 2 | |
| 3 | /// Prints all the elements and their properties to stdout, as a tab-separated table |
| 4 | fn mainrust-analyzer cargo mendeleev 0.8.1 main().() { |
| 5 | let columns: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&str, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>)> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 6 | ( |
| 7 | "Number", |
| 8 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| e.atomic_numberrust-analyzer cargo mendeleev 0.8.1 properties/atomic_number/impl#[Element]atomic_number().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 9 | ), |
| 10 | ("Symbol", Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| e.symbolrust-analyzer cargo mendeleev 0.8.1 properties/symbol/impl#[Element]symbol().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 11 | ( |
| 12 | "Name ", |
| 13 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:<10}", e.namerust-analyzer cargo mendeleev 0.8.1 properties/name/impl#[Element]name().())), |
| 14 | ), |
| 15 | ( |
| 16 | "Year", |
| 17 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| e.year_discoveredrust-analyzer cargo mendeleev 0.8.1 properties/year_discovered/impl#[Element]year_discovered().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 18 | ), |
| 19 | ( |
| 20 | "CPK color", |
| 21 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| { |
| 22 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 23 | "{:<10}", |
| 24 | e.cpk_colorrust-analyzer cargo mendeleev 0.8.1 properties/cpk_color/impl#[Element]cpk_color().() |
| 25 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|c| c.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 26 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 27 | ) |
| 28 | }), |
| 29 | ), |
| 30 | ( |
| 31 | "Jmol color", |
| 32 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| { |
| 33 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 34 | "{:<10}", |
| 35 | e.jmol_colorrust-analyzer cargo mendeleev 0.8.1 properties/jmol_color/impl#[Element]jmol_color().() |
| 36 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|c| c.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 37 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 38 | ) |
| 39 | }), |
| 40 | ), |
| 41 | ( |
| 42 | "Atomic Weight", |
| 43 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:<10}", e.atomic_weightrust-analyzer cargo mendeleev 0.8.1 properties/atomic_weight/impl#[Element]atomic_weight().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 44 | ), |
| 45 | ( |
| 46 | "Atomic Radius", |
| 47 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| { |
| 48 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 49 | "{:10}", |
| 50 | e.atomic_radiusrust-analyzer cargo mendeleev 0.8.1 properties/atomic_radius/impl#[Element]atomic_radius().() |
| 51 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|r| r.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 52 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 53 | ) |
| 54 | }), |
| 55 | ), |
| 56 | ("Period", Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| e.periodrust-analyzer cargo mendeleev 0.8.1 properties/period/impl#[Element]period().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 57 | ( |
| 58 | "Group", |
| 59 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(|e: &Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#| { |
| 60 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:<10}", e.grouprust-analyzer cargo mendeleev 0.8.1 properties/group/impl#[Element]group().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|g| g.group_symbolrust-analyzer cargo mendeleev 0.8.1 properties/group_symbol/impl#[Group]group_symbol().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("")) |
| 61 | }), |
| 62 | ), |
| 63 | ]; |
| 64 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 65 | "{}", |
| 66 | columns |
| 67 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 68 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(name, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().name) |
| 69 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 70 | .joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\t") |
| 71 | ); |
| 72 | for element in Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#::listrust-analyzer cargo mendeleev 0.8.1 element/array/impl#[Element]list().() { |
| 73 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!( |
| 74 | "{}", |
| 75 | columns |
| 76 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 77 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_, prop)| prop(&element)) |
| 78 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 79 | .joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\t") |
| 80 | ); |
| 81 | } |
| 82 | } |