pub enum Group {
IA,
IIA,
// some variants omitted
}Expand description
Each group in the periodic table
Variants§
Implementations§
Source§impl Group
impl Group
Sourcepub const fn group_name(&self) -> Option<&'static str>
pub const fn group_name(&self) -> Option<&'static str>
Returns the group’s trivial name, if any.
use mendeleev::Group;
assert_eq!(Group::IA.group_name(), Some("Alkali metals"));
assert_eq!(Group::VIIIA.group_name(), Some("Noble gases"));
assert_eq!(Group::VIIIB8.group_name(), None);Source§impl Group
impl Group
Sourcepub const fn group_number(&self) -> u32
pub const fn group_number(&self) -> u32
Returns the group’s number in the periodic table.
use mendeleev::Group;
assert_eq!(Group::IA.group_number(), 1);
assert_eq!(Group::VIIIA.group_number(), 18);Source§impl Group
impl Group
Sourcepub const fn group_symbol(&self) -> &'static str
pub const fn group_symbol(&self) -> &'static str
Returns the group’s symbol in the CAS system
use mendeleev::Group;
assert_eq!(Group::IA.group_symbol(), "IA");
assert_eq!(Group::VIIIA.group_symbol(), "VIIIA");
assert_eq!(Group::VIIIB8.group_symbol(), "VIIIB");Examples found in repository?
examples/print_all_elements.rs (line 60)
4fn main() {
5 let columns: Vec<(&str, Box<dyn Fn(&Element) -> String>)> = vec![
6 (
7 "Number",
8 Box::new(|e: &Element| e.atomic_number().to_string()),
9 ),
10 ("Symbol", Box::new(|e: &Element| e.symbol().to_string())),
11 (
12 "Name ",
13 Box::new(|e: &Element| format!("{:<10}", e.name())),
14 ),
15 (
16 "Year",
17 Box::new(|e: &Element| e.year_discovered().to_string()),
18 ),
19 (
20 "CPK color",
21 Box::new(|e: &Element| {
22 format!(
23 "{:<10}",
24 e.cpk_color()
25 .map(|c| c.to_string())
26 .unwrap_or("".to_string()),
27 )
28 }),
29 ),
30 (
31 "Jmol color",
32 Box::new(|e: &Element| {
33 format!(
34 "{:<10}",
35 e.jmol_color()
36 .map(|c| c.to_string())
37 .unwrap_or("".to_string()),
38 )
39 }),
40 ),
41 (
42 "Atomic Weight",
43 Box::new(|e: &Element| format!("{:<10}", e.atomic_weight().to_string())),
44 ),
45 (
46 "Atomic Radius",
47 Box::new(|e: &Element| {
48 format!(
49 "{:10}",
50 e.atomic_radius()
51 .map(|r| r.to_string())
52 .unwrap_or("".to_string())
53 )
54 }),
55 ),
56 ("Period", Box::new(|e: &Element| e.period().to_string())),
57 (
58 "Group",
59 Box::new(|e: &Element| {
60 format!("{:<10}", e.group().map(|g| g.group_symbol()).unwrap_or(""))
61 }),
62 ),
63 ];
64 println!(
65 "{}",
66 columns
67 .iter()
68 .map(|(name, _)| *name)
69 .collect::<Vec<_>>()
70 .join("\t")
71 );
72 for element in Element::list() {
73 println!(
74 "{}",
75 columns
76 .iter()
77 .map(|(_, prop)| prop(&element))
78 .collect::<Vec<_>>()
79 .join("\t")
80 );
81 }
82}Source§impl Group
impl Group
Sourcepub const fn list() -> &'static [Self]
pub const fn list() -> &'static [Self]
Slice containing all groups, ordered by group number
use mendeleev::Group;
use mendeleev::N_GROUPS;
for n in 1..=N_GROUPS {
assert_eq!(Group::list()[n - 1].group_number() as usize, n);
}Examples found in repository?
examples/print_periodic_table.rs (line 6)
4fn main() {
5 for period in 1..=N_PERIODS {
6 for group in Group::list() {
7 let element = Element::list()
8 .iter()
9 .find(|e| e.period() == period && e.group() == Some(*group));
10 match element {
11 Some(element) => print!("{:<4}", element.symbol()),
12 None => print!(" "),
13 }
14 }
15 println!();
16 }
17 println!();
18 for period in 6..=7 {
19 print!(" ");
20 for element in Element::list()
21 .iter()
22 .filter(|el| el.period() == period && el.group().is_none())
23 {
24 print!("{:<4}", element.symbol());
25 }
26 println!();
27 }
28}Trait Implementations§
Source§impl Ord for Group
impl Ord for Group
Source§impl PartialOrd for Group
impl PartialOrd for Group
impl Copy for Group
impl Eq for Group
impl StructuralPartialEq for Group
Auto Trait Implementations§
impl Freeze for Group
impl RefUnwindSafe for Group
impl Send for Group
impl Sync for Group
impl Unpin for Group
impl UnwindSafe for Group
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more