Debian Codegraph @

examples/print_periodic_table.rs

raw symbols SCIP
1 use mendeleevrust-analyzer cargo mendeleev 0.8.1 crate/::{Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#, Grouprust-analyzer cargo mendeleev 0.8.1 group/Group#, N_PERIODSrust-analyzer cargo mendeleev 0.8.1 properties/period/N_PERIODS.};
2
3 /// Prints a simple periodic table to stdout, with only the element symbols
4 fn mainrust-analyzer cargo mendeleev 0.8.1 main().() {
5 for period in 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#N_PERIODSrust-analyzer cargo mendeleev 0.8.1 properties/period/N_PERIODS. {
6 for group in Grouprust-analyzer cargo mendeleev 0.8.1 group/Group#::listrust-analyzer cargo mendeleev 0.8.1 group/array/impl#[Group]list().() {
7 let element = Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#::listrust-analyzer cargo mendeleev 0.8.1 element/array/impl#[Element]list().()
8 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
9 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find().(|e| e.periodrust-analyzer cargo mendeleev 0.8.1 properties/period/impl#[Element]period().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().period && e.grouprust-analyzer cargo mendeleev 0.8.1 properties/group/impl#[Element]group().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().group));
10 match element {
11 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(element) => printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("{:<4}", element.symbolrust-analyzer cargo mendeleev 0.8.1 properties/symbol/impl#[Element]symbol().()),
12 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!(" "),
13 }
14 }
15 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!();
16 }
17 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!();
18 for period in 6..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#7 {
19 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!(" ");
20 for element in Elementrust-analyzer cargo mendeleev 0.8.1 element/Element#::listrust-analyzer cargo mendeleev 0.8.1 element/array/impl#[Element]list().()
21 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
22 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|el| el.periodrust-analyzer cargo mendeleev 0.8.1 properties/period/impl#[Element]period().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().period && el.grouprust-analyzer cargo mendeleev 0.8.1 properties/group/impl#[Element]group().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().())
23 {
24 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("{:<4}", element.symbolrust-analyzer cargo mendeleev 0.8.1 properties/symbol/impl#[Element]symbol().());
25 }
26 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!();
27 }
28 }