pub struct Element {
pub count: usize,
/* private fields */
}Expand description
An individual element. Containing an element from the periodic table and the count of how many there are.
Eg: O2
Fields§
§count: usizeHow many of this element there are. In O2 the count will be 2 and in 2NO3 it will be 3
Implementations§
Source§impl Element
impl Element
Sourcepub fn parse(input: &str) -> Result<Self, ElementError>
pub fn parse(input: &str) -> Result<Self, ElementError>
Parse an element from a str
§Examples
use chem_eq::{Element, error::ElementError};
let el = Element::parse("O2");
assert!(el.is_ok());
let el = Element::parse("H2O");
assert_eq!(el.unwrap_err(), ElementError::TooMuchInput("O".to_string()));Methods from Deref<Target = MendeleevElement>§
Sourcepub fn atomic_number(&self) -> u32
pub fn atomic_number(&self) -> u32
Returns the element’s atomic number, i.e., the number of protons in its nucleus.
use mendeleev::Element;
assert_eq!(Element::H.atomic_number(), 1);
assert_eq!(Element::Og.atomic_number(), 118);Sourcepub fn atomic_radius(&self) -> Option<f64>
pub fn atomic_radius(&self) -> Option<f64>
Returns the element’s empirically measured atomic radius in pm, if available.
use mendeleev::Element;
assert_eq!(Element::H.atomic_radius(), Some(25.0));Sourcepub fn atomic_weight(&self) -> AtomicWeight
pub fn atomic_weight(&self) -> AtomicWeight
Returns the element’s Standard Atomic Weight, if applicable, or its mass number otherwise.
use mendeleev::{Element, AtomicWeight};
assert_eq!(Element::H.atomic_weight(),
AtomicWeight::Interval{range: 1.0078..=1.0082, conventional: 1.008});
assert_eq!(Element::Og.atomic_weight(), AtomicWeight::MassNumber{number: 294});Sourcepub fn cpk_color(&self) -> Option<Color>
pub fn cpk_color(&self) -> Option<Color>
Returns the color for the element in the CPK convention.
use mendeleev::{Element, Color};
assert_eq!(Element::H.cpk_color(), Some(Color{r: 255, g: 255, b: 255}));
assert_eq!(Element::Og.cpk_color(), None);
assert_eq!(Element::Au.cpk_color(), Some(Color{r: 218, g: 165, b: 32}));Sourcepub fn group(&self) -> Option<Group>
pub fn group(&self) -> Option<Group>
Returns the element’s group in the periodic table, if any.
use mendeleev::{Element, Group};
assert_eq!(Element::H.group(), Some(Group::IA));
assert_eq!(Element::Og.group(), Some(Group::VIIIA));
assert_eq!(Element::U.group(), None);Sourcepub fn jmol_color(&self) -> Option<Color>
pub fn jmol_color(&self) -> Option<Color>
Returns the color for the element in the jmol software
use mendeleev::{Element, Color};
assert_eq!(Element::H.jmol_color(), Some(Color{r: 255, g: 255, b: 255}));
assert_eq!(Element::Og.jmol_color(), None);
assert_eq!(Element::Au.jmol_color(), Some(Color{r: 255, g: 209, b: 35}));Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Returns the name of the element in English.
use mendeleev::Element;
assert_eq!(Element::H.name(), "Hydrogen");Sourcepub fn period(&self) -> u32
pub fn period(&self) -> u32
Returns the element’s period number in the periodic table.
use mendeleev::Element;
assert_eq!(Element::H.period(), 1);
assert_eq!(Element::Og.period(), 7);Sourcepub fn symbol(&self) -> &'static str
pub fn symbol(&self) -> &'static str
Returns the symbol for the element
use mendeleev::Element;
assert_eq!(Element::H.symbol(), "H");Sourcepub fn year_discovered(&self) -> YearDiscovered
pub fn year_discovered(&self) -> YearDiscovered
The year in which the element was discovered, if known.
use mendeleev::{Element, YearDiscovered};
assert_eq!(Element::H.year_discovered(), YearDiscovered::Known(1766));
assert_eq!(Element::Og.year_discovered(), YearDiscovered::Known(2002));
assert_eq!(Element::Au.year_discovered(), YearDiscovered::Ancient);Sourcepub fn melting_point(&self) -> Option<f64>
pub fn melting_point(&self) -> Option<f64>
Returns the element’s melting point in Kelvin, if known.
use mendeleev::Element;
assert_eq!(Element::H.melting_point(), Some(14.01));
assert_eq!(Element::C.melting_point(), Some(3820.0));
assert_eq!(Element::Og.melting_point(), None);Sourcepub fn boiling_point(&self) -> Option<f64>
pub fn boiling_point(&self) -> Option<f64>
Returns the element’s boiling point in Kelvin, if known.
use mendeleev::Element;
assert_eq!(Element::H.boiling_point(), Some(20.28));
assert_eq!(Element::C.boiling_point(), Some(5100.0));
assert_eq!(Element::Og.boiling_point(), None);Sourcepub fn fusion_heat(&self) -> Option<f64>
pub fn fusion_heat(&self) -> Option<f64>
Returns the element’s fusion heat in kJ/mol, if known.
use mendeleev::Element;
assert_eq!(Element::H.fusion_heat(), Some(0.117));
assert_eq!(Element::Og.fusion_heat(), None);Sourcepub fn evaporation_heat(&self) -> Option<f64>
pub fn evaporation_heat(&self) -> Option<f64>
Returns the element’s evaporation heat in kJ/mol, if known.
use mendeleev::Element;
assert_eq!(Element::H.evaporation_heat(), Some(0.904));Sourcepub fn electronic_configuration(&self) -> ElectronicConfiguration
pub fn electronic_configuration(&self) -> ElectronicConfiguration
Returns the element’s electronic configuration.
use mendeleev::{Element, SubshellLabel};
let configuration = Element::Li.electronic_configuration();
assert_eq!(configuration.noble_gas, Some(Element::He));
assert_eq!(configuration.valence_subshells[0].shell_number, 2);
assert_eq!(configuration.valence_subshells[0].subshell_label, SubshellLabel::S);
assert_eq!(configuration.valence_subshells[0].number_of_electrons, 1);Sourcepub fn discoverers(&self) -> Option<&'static [&'static str]>
pub fn discoverers(&self) -> Option<&'static [&'static str]>
Returns the persons and/or institutions involved in the discovery of the element, if known.
use mendeleev::Element;
assert_eq!(Element::H.discoverers(), Some(["Henry Cavendish"].as_slice()));
assert_eq!(Element::He.discoverers(), Some(["Sir William Ramsey", "Nils Langet", "P.T.Cleve"].as_slice()));
assert_eq!(Element::Og.discoverers(), Some(["Joint Institute for Nuclear Research"].as_slice()));
assert_eq!(Element::Au.discoverers(), None);Sourcepub fn discovery_location(&self) -> Option<&'static [&'static str]>
pub fn discovery_location(&self) -> Option<&'static [&'static str]>
Returns the location (country, in most cases) where the element was discovered, if known. There can be multiple locations if it was an international effort or if multiple teams discovered or isolated the element independently.
use mendeleev::Element;
assert_eq!(Element::H.discovery_location(), Some(["England"].as_slice()));
assert_eq!(Element::He.discovery_location(), Some(["Scotland", "Sweden"].as_slice()));
assert_eq!(Element::Og.discovery_location(), Some(["Russia"].as_slice()));
assert_eq!(Element::Au.discovery_location(), None);Sourcepub fn oxidation_states(
&self,
category: OxidationStateCategory,
) -> &'static [i8]
pub fn oxidation_states( &self, category: OxidationStateCategory, ) -> &'static [i8]
Returns the element’s oxidation states for the given category.
§Example
use mendeleev::{Element, OxidationStateCategory::{Main, Extended, All}};
assert_eq!(Element::N.oxidation_states(Main), [-3, 3, 5]);
assert_eq!(Element::N.oxidation_states(Extended), [-2, -1, 0, 1, 2, 4]);
assert_eq!(Element::N.oxidation_states(All), [-3, -2, -1, 0, 1, 2, 3, 4, 5]);Trait Implementations§
Source§impl Ord for Element
impl Ord for Element
Source§impl PartialOrd for Element
impl PartialOrd for Element
impl Eq for Element
impl StructuralPartialEq for Element
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more