Enum Element

Source
#[non_exhaustive]
pub enum Element {
Show 118 variants Hydrogen, Helium, Lithium, Beryllium, Boron, Carbon, Nitrogen, Oxygen, Fluorine, Neon, Sodium, Magnesium, Aluminium, Silicon, Phosphorus, Sulfur, Chlorine, Argon, Potassium, Calcium, Scandium, Titanium, Vanadium, Chromium, Manganese, Iron, Cobalt, Nickel, Copper, Zinc, Gallium, Germanium, Arsenic, Selenium, Bromine, Krypton, Rubidium, Strontium, Yttrium, Zirconium, Niobium, Molybdenum, Technetium, Ruthenium, Rhodium, Palladium, Silver, Cadmium, Indium, Tin, Antimony, Tellurium, Iodine, Xenon, Caesium, Barium, Lanthanum, Cerium, Praseodymium, Neodymium, Promethium, Samarium, Europium, Gadolinium, Terbium, Dysprosium, Holmium, Erbium, Thulium, Ytterbium, Lutetium, Hafnium, Tantalum, Tungsten, Rhenium, Osmium, Iridium, Platinum, Gold, Mercury, Thallium, Lead, Bismuth, Polonium, Astatine, Radon, Francium, Radium, Actinium, Thorium, Protactinium, Uranium, Neptunium, Plutonium, Americium, Curium, Berkelium, Californium, Einsteinium, Fermium, Mendelevium, Nobelium, Lawrencium, Rutherfordium, Dubnium, Seaborgium, Bohrium, Hassium, Meitnerium, Darmstadtium, Roentgenium, Copernicium, Nihonium, Flerovium, Moscovium, Livermorium, Tennessine, Oganesson,
}
Expand description

Periodic table chemical element.

§Examples

use nkl::core::Element;

let hydrogen = Element::Hydrogen;
let helium = Element::from_name("Helium").unwrap();
let lithium = Element::from_symbol("Li").unwrap();
let beryllium = Element::from_atomic_number(4).unwrap();

assert_eq!(hydrogen.name(), "Hydrogen");
assert_eq!(hydrogen.symbol(), "H");
assert_eq!(hydrogen.atomic_number(), 1);
assert_eq!(hydrogen.block(), "s");
assert_eq!(hydrogen.period(), 1);
assert_eq!(hydrogen.group(), Some(1));

§Notes

  • Chemical element from Hydrogen (Z = 1) to Oganesson (Z = 118) are included.
  • Element enum is marked as non exhaustive for future-proofing.

§References

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Hydrogen

Hydrogen, symbol=‘H’, atomic number Z=1

§

Helium

Helium, symbol=‘He’, atomic number Z=2

§

Lithium

Lithium, symbol=‘Li’, atomic number Z=3

§

Beryllium

Beryllium, symbol=‘Be’, atomic number Z=4

§

Boron

Boron, symbol=‘B’, atomic number Z=5

§

Carbon

Carbon, symbol=‘C’, atomic number Z=6

§

Nitrogen

Nitrogen, symbol=‘N’, atomic number Z=7

§

Oxygen

Oxygen, symbol=‘O’, atomic number Z=8

§

Fluorine

Fluorine, symbol=‘F’, atomic number Z=9

§

Neon

Neon, symbol=‘Ne’, atomic number Z=10

§

Sodium

Sodium, symbol=‘Na’, atomic number Z=11

§

Magnesium

Magnesium, symbol=‘Mg’, atomic number Z=12

§

Aluminium

Aluminium, symbol=‘Al’, atomic number Z=13

§

Silicon

Silicon, symbol=‘Si’, atomic number Z=14

§

Phosphorus

Phosphorus, symbol=‘P’, atomic number Z=15

§

Sulfur

Sulfur, symbol=‘S’, atomic number Z=16

§

Chlorine

Chlorine, symbol=‘Cl’, atomic number Z=17

§

Argon

Argon, symbol=‘Ar’, atomic number Z=18

§

Potassium

Potassium, symbol=‘K’, atomic number Z=19

§

Calcium

Calcium, symbol=‘Ca’, atomic number Z=20

§

Scandium

Scandium, symbol=‘Sc’, atomic number Z=21

§

Titanium

Titanium, symbol=‘Ti’, atomic number Z=22

§

Vanadium

Vanadium, symbol=‘V’, atomic number Z=23

§

Chromium

Chromium, symbol=‘Cr’, atomic number Z=24

§

Manganese

Manganese, symbol=‘Mn’, atomic number Z=25

§

Iron

Iron, symbol=‘Fe’, atomic number Z=26

§

Cobalt

Cobalt, symbol=‘Co’, atomic number Z=27

§

Nickel

Nickel, symbol=‘Ni’, atomic number Z=28

§

Copper

Copper, symbol=‘Cu’, atomic number Z=29

§

Zinc

Zinc, symbol=‘Zn’, atomic number Z=30

§

Gallium

Gallium, symbol=‘Ga’, atomic number Z=31

§

Germanium

Germanium, symbol=‘Ge’, atomic number Z=32

§

Arsenic

Arsenic, symbol=‘As’, atomic number Z=33

§

Selenium

Selenium, symbol=‘Se’, atomic number Z=34

§

Bromine

Bromine, symbol=‘Br’, atomic number Z=35

§

Krypton

Krypton, symbol=‘Kr’, atomic number Z=36

§

Rubidium

Rubidium, symbol=‘Rb’, atomic number Z=37

§

Strontium

Strontium, symbol=‘Sr’, atomic number Z=38

§

Yttrium

Yttrium, symbol=‘Y’, atomic number Z=39

§

Zirconium

Zirconium, symbol=‘Zr’, atomic number Z=40

§

Niobium

Niobium, symbol=‘Nb’, atomic number Z=41

§

Molybdenum

Molybdenum, symbol=‘Mo’, atomic number Z=42

§

Technetium

Technetium, symbol=‘Tc’, atomic number Z=43

§

Ruthenium

Ruthenium, symbol=‘Ru’, atomic number Z=44

§

Rhodium

Rhodium, symbol=‘Rh’, atomic number Z=45

§

Palladium

Palladium, symbol=‘Pd’, atomic number Z=46

§

Silver

Silver, symbol=‘Ag’, atomic number Z=47

§

Cadmium

Cadmium, symbol=‘Cd’, atomic number Z=48

§

Indium

Indium, symbol=‘In’, atomic number Z=49

§

Tin

Tin, symbol=‘Sn’, atomic number Z=50

§

Antimony

Antimony, symbol=‘Sb’, atomic number Z=51

§

Tellurium

Tellurium, symbol=‘Te’, atomic number Z=52

§

Iodine

Iodine, symbol=‘I’, atomic number Z=53

§

Xenon

Xenon, symbol=‘Xe’, atomic number Z=54

§

Caesium

Caesium, symbol=‘Cs’, atomic number Z=55

§

Barium

Barium, symbol=‘Ba’, atomic number Z=56

§

Lanthanum

Lanthanum, symbol=‘La’, atomic number Z=57

§

Cerium

Cerium, symbol=‘Ce’, atomic number Z=58

§

Praseodymium

Praseodymium, symbol=‘Pr’, atomic number Z=59

§

Neodymium

Neodymium, symbol=‘Nd’, atomic number Z=60

§

Promethium

Promethium, symbol=‘Pm’, atomic number Z=61

§

Samarium

Samarium, symbol=‘Sm’, atomic number Z=62

§

Europium

Europium, symbol=‘Eu’, atomic number Z=63

§

Gadolinium

Gadolinium, symbol=‘Gd’, atomic number Z=64

§

Terbium

Terbium, symbol=‘Tb’, atomic number Z=65

§

Dysprosium

Dysprosium, symbol=‘Dy’, atomic number Z=66

§

Holmium

Holmium, symbol=‘Ho’, atomic number Z=67

§

Erbium

Erbium, symbol=‘Er’, atomic number Z=68

§

Thulium

Thulium, symbol=‘Tm’, atomic number Z=69

§

Ytterbium

Ytterbium, symbol=‘Yb’, atomic number Z=70

§

Lutetium

Lutetium, symbol=‘Lu’, atomic number Z=71

§

Hafnium

Hafnium, symbol=‘Hf’, atomic number Z=72

§

Tantalum

Tantalum, symbol=‘Ta’, atomic number Z=73

§

Tungsten

Tungsten, symbol=‘W’, atomic number Z=74

§

Rhenium

Rhenium, symbol=‘Re’, atomic number Z=75

§

Osmium

Osmium, symbol=‘Os’, atomic number Z=76

§

Iridium

Iridium, symbol=‘Ir’, atomic number Z=77

§

Platinum

Platinum, symbol=‘Pt’, atomic number Z=78

§

Gold

Gold, symbol=‘Au’, atomic number Z=79

§

Mercury

Mercury, symbol=‘Hg’, atomic number Z=80

§

Thallium

Thallium, symbol=‘Tl’, atomic number Z=81

§

Lead

Lead, symbol=‘Pb’, atomic number Z=82

§

Bismuth

Bismuth, symbol=‘Bi’, atomic number Z=83

§

Polonium

Polonium, symbol=‘Po’, atomic number Z=84

§

Astatine

Astatine, symbol=‘At’, atomic number Z=85

§

Radon

Radon, symbol=‘Rn’, atomic number Z=86

§

Francium

Francium, symbol=‘Fr’, atomic number Z=87

§

Radium

Radium, symbol=‘Ra’, atomic number Z=88

§

Actinium

Actinium, symbol=‘Ac’, atomic number Z=89

§

Thorium

Thorium, symbol=‘Th’, atomic number Z=90

§

Protactinium

Protactinium, symbol=‘Pa’, atomic number Z=91

§

Uranium

Uranium, symbol=‘U’, atomic number Z=92

§

Neptunium

Neptunium, symbol=‘Np’, atomic number Z=93

§

Plutonium

Plutonium, symbol=‘Pu’, atomic number Z=94

§

Americium

Americium, symbol=‘Am’, atomic number Z=95

§

Curium

Curium, symbol=‘Cm’, atomic number Z=96

§

Berkelium

Berkelium, symbol=‘Bk’, atomic number Z=97

§

Californium

Californium, symbol=‘Cf’, atomic number Z=98

§

Einsteinium

Einsteinium, symbol=‘Es’, atomic number Z=99

§

Fermium

Fermium, symbol=‘Fm’, atomic number Z=100

§

Mendelevium

Mendelevium, symbol=‘Md’, atomic number Z=101

§

Nobelium

Nobelium, symbol=‘No’, atomic number Z=102

§

Lawrencium

Lawrencium, symbol=‘Lr’, atomic number Z=103

§

Rutherfordium

Rutherfordium, symbol=‘Rf’, atomic number Z=104

§

Dubnium

Dubnium, symbol=‘Db’, atomic number Z=105

§

Seaborgium

Seaborgium, symbol=‘Sg’, atomic number Z=106

§

Bohrium

Bohrium, symbol=‘Bh’, atomic number Z=107

§

Hassium

Hassium, symbol=‘Hs’, atomic number Z=108

§

Meitnerium

Meitnerium, symbol=‘Mt’, atomic number Z=109

§

Darmstadtium

Darmstadtium, symbol=‘Ds’, atomic number Z=110

§

Roentgenium

Roentgenium, symbol=‘Rg’, atomic number Z=111

§

Copernicium

Copernicium, symbol=‘Cn’, atomic number Z=112

§

Nihonium

Nihonium, symbol=‘Nh’, atomic number Z=113

§

Flerovium

Flerovium, symbol=‘Fl’, atomic number Z=114

§

Moscovium

Moscovium, symbol=‘Mc’, atomic number Z=115

§

Livermorium

Livermorium, symbol=‘Lv’, atomic number Z=116

§

Tennessine

Tennessine, symbol=‘Ts’, atomic number Z=117

§

Oganesson

Oganesson, symbol=‘Og’, atomic number Z=118

Implementations§

Source§

impl Element

Source

pub fn from_name(name: &str) -> Option<Self>

Returns Element corresponding to specified name (case insensitive).

§Returns
  • Some(element) if name is a standard element name (case insensitive)
  • None if name is not a standard element name
§Examples
use nkl::core::Element;

assert_eq!(Element::from_name("Hydrogen"), Some(Element::Hydrogen));
Source

pub fn from_symbol(symbol: &str) -> Option<Self>

Returns Element corresponding to specified symbol.

§Returns
  • Some(element) if symbol is a standard element symbol (case insensitive)
  • None if symbol is not a standard element symbol
§Examples
use nkl::core::Element;

assert_eq!(Element::from_symbol("H"), Some(Element::Hydrogen));
Source

pub fn from_atomic_number(atomic_number: u32) -> Option<Self>

Returns Element corresponding to specified atomic number.

§Returns
  • Some(element) if atomic_number[1, 118]
  • None if atomic_number[1, 118]
§Examples
use nkl::core::Element;

assert_eq!(Element::from_atomic_number(1), Some(Element::Hydrogen));
Source

pub fn name(&self) -> &str

Returns Element’s name.

§Examples
use nkl::core::Element;

assert_eq!(Element::Hydrogen.name(), "Hydrogen");
Source

pub fn symbol(&self) -> &str

Returns Element’s symbol.

§Examples
use nkl::core::Element;

assert_eq!(Element::Hydrogen.symbol(), "H");
Source

pub fn atomic_number(&self) -> u32

Returns Element’s atomic number Z.

§Examples
use nkl::core::Element;

assert_eq!(Element::Hydrogen.atomic_number(), 1);
Source

pub fn period(&self) -> u32

Returns Element’s period (periodic table row number).

§Examples
use nkl::core::Element;

assert_eq!(Element::Hydrogen.period(), 1);
§References

Wikipedia: Period (periodic table)

Source

pub fn group(&self) -> Option<u32>

Returns Element’s group (periodic table column number).

§Examples
use nkl::core::Element;

assert_eq!(Element::Hydrogen.group(), Some(1));
§Notes

Lanthanides and actinides (f-block) do not have a group.

§References

Wikipedia: Group (periodic table)

Source

pub fn block(&self) -> &str

Returns Element’s block (characteristic orbital set).

§Examples
use nkl::core::Element;

assert_eq!(Element::Hydrogen.block(), "s");
§References

Wikipedia: Block (periodic table)

Source

pub fn iter() -> impl Iterator<Item = Element>

Returns an iterator over all elements.

§Examples
use nkl::core::Element;

for element in Element::iter() {
    println!("{}", element.name());
}
Source

pub fn is_alkali_metal(&self) -> bool

Returns true if this Element is an alkali metal.

§Examples
use nkl::core::Element;

assert!(Element::Lithium.is_alkali_metal());
assert!(!Element::Iron.is_alkali_metal());
§References

Wikipedia: Alkali metal

Source

pub fn is_alkaline_earth_metal(&self) -> bool

Returns true if this Element is an alkaline earth metal.

§Examples
use nkl::core::Element;

assert!(Element::Beryllium.is_alkaline_earth_metal());
assert!(!Element::Iron.is_alkaline_earth_metal());
§References

Wikipedia: Alkaline earth metal

Source

pub fn is_pnictogen(&self) -> bool

Returns true if this Element is a pnictogen.

§Examples
use nkl::core::Element;

assert!(Element::Nitrogen.is_pnictogen());
assert!(!Element::Iron.is_pnictogen());
§References

Wikipedia: Pnictogen

Source

pub fn is_chalcogen(&self) -> bool

Returns true if this Element is a chalcogen.

§Examples
use nkl::core::Element;

assert!(Element::Oxygen.is_chalcogen());
assert!(!Element::Iron.is_chalcogen());
§References

Wikipedia: Chalcogen

Source

pub fn is_halogen(&self) -> bool

Returns true if this Element is an halogen.

§Examples
use nkl::core::Element;

assert!(Element::Fluorine.is_halogen());
assert!(!Element::Iron.is_halogen());
§References

Wikipedia: Halogen

Source

pub fn is_noble_gas(&self) -> bool

Returns true if this Element is a noble gas.

§Examples
use nkl::core::Element;

assert!(Element::Helium.is_noble_gas());
assert!(!Element::Iron.is_noble_gas());
§References

Wikipedia: Noble gas

Trait Implementations§

Source§

impl Clone for Element

Source§

fn clone(&self) -> Element

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Element

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Element

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Element

Source§

fn cmp(&self, other: &Element) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Element

Source§

fn eq(&self, other: &Element) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Element

Source§

fn partial_cmp(&self, other: &Element) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Element

Source§

impl Eq for Element

Source§

impl StructuralPartialEq for Element

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.